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
Line 
1#include "stdio.h"
2
3///////
4int main2()
5{
6        int opx;
7        int opy;
8
9        tty_puts(" TASK 2 : PGCD \n");
10
11        while (1)
12    {
13                tty_puts("\n*******************\n");
14                tty_puts("operand X = ");
15                tty_getw_irq(&opx);
16                tty_printf("%d\n",opx);
17                tty_printf("operand Y = ");
18                tty_getw_irq(&opy);
19                tty_printf("%d\n",opy);
20
21                if( (opx < 1) || (opy < 1) )
22        {
23                        tty_puts("operands must be larger than 0\n");
24                }
25        else
26        {
27                        while (opx != opy)
28            {
29                                if(opx > opy)   opx = opx - opy;
30                                else            opy = opy - opx;
31                        }
32                        tty_printf("pgcd = %d\n", opx);
33                }
34        }
35        return 0;
36} // end main2
Note: See TracBrowser for help on using the repository browser.