题目链接:https://www.luogu.org/problem/P5015
这道题目较简单,考察字符串的输入和处理。
代码如下:
#include <bits/stdc++.h>
char c;
int cnt;
int main() {
while (c = getchar()) {
if (c == EOF || c == '\n') break;
if (c != ' ') cnt ++;
}
printf("%d\n", cnt);
return 0;
}
题目链接:https://www.luogu.org/problem/P5015
这道题目较简单,考察字符串的输入和处理。
代码如下:
#include <bits/stdc++.h>
char c;
int cnt;
int main() {
while (c = getchar()) {
if (c == EOF || c == '\n') break;
if (c != ' ') cnt ++;
}
printf("%d\n", cnt);
return 0;
}