Last change
on this file since 523 was
475,
checked in by viala@…, 6 years ago
|
[userland] Add void type to function prototypes with no parameter
|
File size:
1.3 KB
|
Rev | Line | |
---|
[417] | 1 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 2 | // File : pgcd.c |
---|
| 3 | // Date : November 2017 |
---|
| 4 | // Author : Alain Greiner <alain.greiner@lip6.fr> |
---|
| 5 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 6 | // This single thread interactive application computes the PGCD. |
---|
| 7 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 8 | |
---|
| 9 | |
---|
[436] | 10 | #include <stdio.h> |
---|
[465] | 11 | #include <stdlib.h> |
---|
[445] | 12 | #include <almosmkh.h> |
---|
[417] | 13 | |
---|
| 14 | /////////// |
---|
[475] | 15 | void main( void ) |
---|
[417] | 16 | { |
---|
[436] | 17 | int opx; |
---|
| 18 | int opy; |
---|
| 19 | unsigned long long cycle; |
---|
[417] | 20 | |
---|
[436] | 21 | get_cycle( &cycle ); |
---|
[445] | 22 | printf( "\n\n[PGCD] starts / cycle %d\n", (unsigned int)cycle ); |
---|
[417] | 23 | |
---|
| 24 | while (1) |
---|
| 25 | { |
---|
| 26 | printf("\n*******************\n"); |
---|
| 27 | printf("operand X = "); |
---|
| 28 | opx = getint(); |
---|
| 29 | printf("\n"); |
---|
| 30 | printf("operand Y = "); |
---|
| 31 | opy = getint(); |
---|
| 32 | printf("\n"); |
---|
| 33 | |
---|
| 34 | if( (opx == 0) || (opy == 0) ) |
---|
| 35 | { |
---|
[446] | 36 | printf("operands must be positive and larger than 0 => exit\n"); |
---|
| 37 | exit( 0 ); |
---|
[417] | 38 | } |
---|
| 39 | else |
---|
| 40 | { |
---|
| 41 | while (opx != opy) |
---|
| 42 | { |
---|
| 43 | if(opx > opy) opx = opx - opy; |
---|
| 44 | else opy = opy - opx; |
---|
| 45 | } |
---|
[442] | 46 | printf("pgcd = %d", opx); |
---|
[417] | 47 | } |
---|
| 48 | } |
---|
| 49 | } // end pgcd |
---|
| 50 | |
---|
Note: See
TracBrowser
for help on using the repository browser.