author | Markus Bröker <mbroeker@largo.dyndns.tv> |
Sat, 13 Dec 2008 17:58:17 +0100 | |
changeset 25 | 6cf883f9c506 |
parent 9 | c3fecc82ade6 |
child 27 | 81a574d60c15 |
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 |
} |