回答編集履歴
1
追記
test
CHANGED
@@ -25,4 +25,30 @@
|
|
25
25
|
std::cout << std::count_if(str.begin(), str.end(), [](char ch) { return std::isalpha(ch);}) << std::endl;
|
26
26
|
}
|
27
27
|
```
|
28
|
+
[追記] C版
|
29
|
+
```C
|
30
|
+
#include <stdio.h>
|
31
|
+
#include <ctype.h>
|
28
32
|
|
33
|
+
int main() {
|
34
|
+
const char* str =
|
35
|
+
"You can sit before the desk (or in front of the desk). The professor can sit on "
|
36
|
+
"the desk (when he's being informal) or behind the desk, and then his feet are "
|
37
|
+
"under the desk or beneath the desk. He can stand beside the desk (meaning next "
|
38
|
+
"to the desk), before the desk, between the desk and you, or even on the desk (if "
|
39
|
+
"he's really strange). If he's clumsy, he can bump into the desk or try to walk "
|
40
|
+
"through the desk (and stuff would fall off the desk). Passing his hands over the "
|
41
|
+
"desk or resting his elbows upon the desk, he often looks across the desk and "
|
42
|
+
"speaks of the desk or concerning the desk as if there were nothing else like the "
|
43
|
+
"desk. Because he thinks of nothing except the desk, sometimes you wonder about "
|
44
|
+
"the desk, what's in the desk, what he paid for the desk, and if he could live "
|
45
|
+
"without the desk. You can walk toward the desk, to the desk, around the desk, by "
|
46
|
+
"the desk, and even past the desk while he sits at the desk or leans against the "
|
47
|
+
"desk.";
|
48
|
+
|
49
|
+
int count = 0;
|
50
|
+
while ( *str ) if ( isalpha(*str++) ) ++count;
|
51
|
+
printf("%d alphabets.\n", count);
|
52
|
+
return 0;
|
53
|
+
}
|
54
|
+
```
|