Skip to content

Commit

Permalink
Accomplish 6_21
Browse files Browse the repository at this point in the history
Accomplish 6_21
  • Loading branch information
PwwwLe committed May 13, 2023
1 parent 95f474f commit a4a8bbb
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Chapter6/6_21/Test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// Created by Pwl on 2023/5/13.
//

#include <iostream>

using namespace std;

int Count(const char *str) {
int count = 0;
for (int i = 0; i < str[i]; ++i) {
if ((str[i] > 'a' && str[i] < 'z') || (str[i] > 'A' && str[i] < 'Z')) {
count++;
}
}
return count;
}

int main() {
cout << "Please enter an English sentence: " << endl;
char str[999];
cin >> str;
cout << "There are " << Count(str) << " characters in this sentence." << endl;
return 0;
}

0 comments on commit a4a8bbb

Please sign in to comment.