思路:直接用一个计数器记录扔过来的数字个数,如果遇到了250,则输出计数器即可。

C语言代码:

#include <stdio.h>

int main() {
    int num, count = 1;
    while (scanf("%d", &num) != EOF) {
        if (num == 250) {
            printf("%d\n", count);
            break;
        }
        count++;
    }
    return 0;
}
C语言代码:查找第一个出现的250

原文地址: https://www.cveoy.top/t/topic/oPOQ 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录