Created
November 18, 2016 08:19
-
-
Save koluku/16232a9ea3a0b19a6ddefab19c435c35 to your computer and use it in GitHub Desktop.
This file contains 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
/* | |
* Exercise 8-1a, oddmm.c | |
*/ | |
#include <stdio.h> | |
int main(void){ | |
int i = 0; | |
int max = 0, min = 0, log; | |
while(1){ | |
scanf("%d", &log); | |
if(log == -1) { | |
break; | |
} | |
if(log%2 != 0) { | |
if(i == 0) { | |
max = log; | |
min = log; | |
i++; | |
} | |
else { | |
if(max < log){ | |
max = log; | |
} | |
else if(min > log){ | |
min = log; | |
} | |
} | |
} | |
} | |
if(max == 0 || min == 0) { | |
printf("none.\n"); | |
} | |
else { | |
printf("max=%d, min=%d.\n", max, min); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment