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