#include <stdio.h> int main() { int ch = 0; int line = 1; int flag = 1; while ((ch = getchar()) != EOF) { if (flag) { printf("%d", line); line++; flag = 0; } if (ch == ‘\n‘) { flag = 1; } putchar(ch); } return 0; }
时间: 2024-12-19 19:50:49
#include <stdio.h> int main() { int ch = 0; int line = 1; int flag = 1; while ((ch = getchar()) != EOF) { if (flag) { printf("%d", line); line++; flag = 0; } if (ch == ‘\n‘) { flag = 1; } putchar(ch); } return 0; }