2020-03-05 13:35:46 +01:00
|
|
|
#include <stdio.h>
|
2020-03-05 13:51:34 +01:00
|
|
|
#include <stdlib.h>
|
2020-03-05 13:35:46 +01:00
|
|
|
#include "main.h"
|
|
|
|
#include "minmax.h"
|
|
|
|
|
|
|
|
int get_userguess(){
|
|
|
|
int x = -1;
|
|
|
|
int ok = -1;
|
|
|
|
while( ok != 1){
|
|
|
|
ok = scanf("%d", &x);
|
|
|
|
if(ok == EOF){
|
|
|
|
printf("\ncaught Ctrl+D...\n");
|
|
|
|
ok = 1;
|
|
|
|
x = 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(ok == 0){
|
|
|
|
while (fgetc(stdin) != '\n'){
|
|
|
|
}
|
|
|
|
printf("[*] give me a correct value\n");
|
|
|
|
printf("[*] stop gibbering around\n my guess >>> ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
|
|
|
int lemmego(){
|
|
|
|
printf("[*] you wished to go, quitting...\n");
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
int selection, max, min = 0;
|
|
|
|
|
|
|
|
while ( selection != 8 ) {
|
|
|
|
printf("\npick a choice\n");
|
|
|
|
printf("1 - max\n"
|
|
|
|
"2 - min\n"
|
2020-03-05 13:51:34 +01:00
|
|
|
"3 - nothing..\n"
|
|
|
|
"4 - here yet\n"
|
2020-03-05 13:35:46 +01:00
|
|
|
"8 - quit\n"
|
|
|
|
">> ");
|
|
|
|
|
|
|
|
selection = get_userguess();
|
|
|
|
|
|
|
|
switch ( selection ) {
|
|
|
|
case 1:
|
|
|
|
max = maximum();
|
|
|
|
printf("maximum je %d\n", max);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
min = minimum();
|
|
|
|
printf("minumum je %d\n", min);
|
|
|
|
break;
|
2020-03-05 13:51:34 +01:00
|
|
|
case 3:
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
break;
|
2020-03-05 13:35:46 +01:00
|
|
|
case 8:
|
|
|
|
lemmego();
|
|
|
|
return 9000;
|
|
|
|
default:
|
|
|
|
printf("invalid option\n");
|
|
|
|
selection = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|