Last change
on this file since 544 was
475,
checked in by viala@…, 6 years ago
|
[userland] Add void type to function prototypes with no parameter
|
File size:
1.3 KB
|
Line | |
---|
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 | |
---|
10 | #include <stdio.h> |
---|
11 | #include <stdlib.h> |
---|
12 | #include <almosmkh.h> |
---|
13 | |
---|
14 | /////////// |
---|
15 | void main( void ) |
---|
16 | { |
---|
17 | int opx; |
---|
18 | int opy; |
---|
19 | unsigned long long cycle; |
---|
20 | |
---|
21 | get_cycle( &cycle ); |
---|
22 | printf( "\n\n[PGCD] starts / cycle %d\n", (unsigned int)cycle ); |
---|
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 | { |
---|
36 | printf("operands must be positive and larger than 0 => exit\n"); |
---|
37 | exit( 0 ); |
---|
38 | } |
---|
39 | else |
---|
40 | { |
---|
41 | while (opx != opy) |
---|
42 | { |
---|
43 | if(opx > opy) opx = opx - opy; |
---|
44 | else opy = opy - opx; |
---|
45 | } |
---|
46 | printf("pgcd = %d", opx); |
---|
47 | } |
---|
48 | } |
---|
49 | } // end pgcd |
---|
50 | |
---|
Note: See
TracBrowser
for help on using the repository browser.