author | Markus Bröker <mbroeker@largo.dyndns.tv> |
Thu, 16 Apr 2009 12:49:11 +0200 | |
changeset 31 | c95a6a7e305c |
parent 29 | 7abf6146898e |
child 48 | b94d657a9acb |
permissions | -rw-r--r-- |
0 | 1 |
/** |
9
c3fecc82ade6
standard tags for git projects
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
2 |
* test/demos/max.c |
c3fecc82ade6
standard tags for git projects
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
3 |
* Copyright (C) 2008 Markus Broeker |
0 | 4 |
*/ |
9
c3fecc82ade6
standard tags for git projects
Markus Bröker <mbroeker@largo.dyndns.tv>
parents:
0
diff
changeset
|
5 |
|
0 | 6 |
#include <stdio.h> |
7 |
#include <stdlib.h> |
|
8 |
||
9 |
unsigned int max (unsigned int a, unsigned int b) |
|
10 |
{ |
|
11 |
return (a * (a > b) + b * (b > a)); |
|
12 |
} |
|
13 |
||
14 |
int main (int argc, char **argv) |
|
15 |
{ |
|
16 |
unsigned int a; |
|
17 |
unsigned int b; |
|
18 |
||
19 |
if (argc != 3) { |
|
20 |
printf ("Usage: %s value1 value2\n", argv[0]); |
|
21 |
return EXIT_SUCCESS; |
|
22 |
} |
|
23 |
a = atoi (argv[1]); |
|
24 |
b = atoi (argv[2]); |
|
25 |
||
26 |
printf ("%u\n", max (a, b)); |
|
27 |
||
28 |
return EXIT_SUCCESS; |
|
29 |
} |