Skip to content

Instantly share code, notes, and snippets.

@koluku
Created November 18, 2016 08:19
Show Gist options
  • Save koluku/16232a9ea3a0b19a6ddefab19c435c35 to your computer and use it in GitHub Desktop.
Save koluku/16232a9ea3a0b19a6ddefab19c435c35 to your computer and use it in GitHub Desktop.
/*
* 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