Last change
on this file since 94 was
61,
checked in by porquet, 13 years ago
|
add new TP04 folder for students
|
File size:
595 bytes
|
Line | |
---|
1 | #include "stdio.h" |
---|
2 | |
---|
3 | /////// |
---|
4 | int 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("\n"); |
---|
17 | tty_printf("operand Y = "); |
---|
18 | tty_getw_irq(&opy); |
---|
19 | tty_printf("\n"); |
---|
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.