Created
March 9, 2015 12:26
-
-
Save zapstar/2e0e3eea8de029417d2d to your computer and use it in GitHub Desktop.
Find the two largest numbers among the three.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
void max2(int a, int b, int c) { | |
int first, second; | |
printf("a = %d, b = %d, c = %d\n", a, b, c); | |
if (a > b) { | |
second = a; | |
if (a > c) { | |
first = a; | |
if (b > c) { | |
second = b; | |
} else { | |
second = c; | |
} | |
} else { | |
first = c; | |
} | |
} else { | |
second = b; | |
if (b > c) { | |
first = b; | |
if (a > c) { | |
second = a; | |
} else { | |
second = c; | |
} | |
} else { | |
first = c; | |
} | |
} | |
printf("first = %d, second = %d\n", first, second); | |
} | |
int main() { | |
int a, b, c; | |
scanf("%d %d %d", &a, &b, &c); | |
max2(a, b, c); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment