source: soft/tp18/correction/main2.c @ 60

Last change on this file since 60 was 44, checked in by alain, 13 years ago
File size: 607 bytes
RevLine 
[25]1#include "stdio.h"
2
[44]3///////
[25]4int main2()
5{
6        int opx;
7        int opy;
8
9        tty_puts(" TASK 2 : PGCD \n");
10
[44]11        while (1)
12    {
[25]13                tty_puts("\n*******************\n");
14                tty_puts("operand X = ");
15                tty_getw_irq(&opx);
[44]16                tty_printf("%d\n",opx);
[25]17                tty_printf("operand Y = ");
18                tty_getw_irq(&opy);
[44]19                tty_printf("%d\n",opy);
20
21                if( (opx < 1) || (opy < 1) )
22        {
[25]23                        tty_puts("operands must be larger than 0\n");
[44]24                }
25        else
26        {
27                        while (opx != opy)
28            {
29                                if(opx > opy)   opx = opx - opy;
30                                else            opy = opy - opx;
[25]31                        }
[44]32                        tty_printf("pgcd = %d\n", opx);
[25]33                }
34        }
35        return 0;
[44]36} // end main2
Note: See TracBrowser for help on using the repository browser.