Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main(void) {
- const char *p = "This is my computer.";
- int count = 0;
- for (int in_word = 0; *p; p++) {
- if (*p == ' ' || *p == '.') {
- if (in_word) {
- count++;
- in_word = 0;
- }
- } else {
- in_word = 1;
- }
- }
- cout << "①単語数= " << count << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement