標準入力から一行づつ読み込み最大値を表示(Cの場合)
#include <stdio.h> #include <string.h> int main(){ int max; char buf[1000]; char* num; int flag = 0; while(fgets(buf, 1000,stdin) != NULL){ num = strtok(buf," \n"); while(num != NULL){ if(flag == 0 || max < atoi(num)){ flag = 1; max = atoi(num); } num =strtok(NULL,"\n"); } } printf("%d\n",max); return 0; }