Last change
on this file since 432 was
427,
checked in by alain, 7 years ago
|
Several processes KSH[i] can be launched by the INIT process.
|
File size:
1.1 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 <stdlib.h> |
---|
11 | |
---|
12 | |
---|
13 | /////////// |
---|
14 | void main() |
---|
15 | { |
---|
16 | int opx; |
---|
17 | int opy; |
---|
18 | char c; |
---|
19 | |
---|
20 | printf( "*** Starting interactive pgcd ***\n\n" ); |
---|
21 | |
---|
22 | while (1) |
---|
23 | { |
---|
24 | printf("\n*******************\n"); |
---|
25 | printf("operand X = "); |
---|
26 | opx = getint(); |
---|
27 | printf("\n"); |
---|
28 | printf("operand Y = "); |
---|
29 | opy = getint(); |
---|
30 | printf("\n"); |
---|
31 | |
---|
32 | if( (opx == 0) || (opy == 0) ) |
---|
33 | { |
---|
34 | printf("operands must be positive and larger than 0\n"); |
---|
35 | } |
---|
36 | else |
---|
37 | { |
---|
38 | while (opx != opy) |
---|
39 | { |
---|
40 | if(opx > opy) opx = opx - opy; |
---|
41 | else opy = opy - opx; |
---|
42 | } |
---|
43 | printf("pgcd = %d\n", opx); |
---|
44 | } |
---|
45 | } |
---|
46 | } // end pgcd |
---|
47 | |
---|
Note: See
TracBrowser
for help on using the repository browser.