07/06/28 01:00:55
>>392 こんなのはどうかな。
#include <stdio.h>
#include <ctype.h>
int main(void)
{
int c, max = -1, m, n, nc = 0, f, sign = 1;
while ((c = getchar()) != EOF) {
if (isdigit(c)) {
n = f = 0;
do {
if ((m = n * 10 + c - '0') < n) f = 1;
n = m;
} while ((c = getchar()) != EOF && isdigit(c));
ungetc(c, stdin);
if (f) puts("桁あふれしますた");
else {
n *= sign;
printf("%d\n", n);
if (n > max) max = n;
if (++nc == 10) break;
}
}
else if (c == '-') { sign = -1; }
else sign = 1;
}
if (max != -1) printf("最大値: %d\n", max);
return 0;
}