-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalyzeString.cpp
41 lines (34 loc) · 1.05 KB
/
analyzeString.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <iostream>
using namespace std;
void analyzeString(string text) {
int letters = 0; // usguud
int digits = 0; // tsifruud
int spaces = 0; // hooson zai
int special = 0; // tusgai temdegt
// text-n buh temdegtuudiig shalgah
for(int i = 0; i < text.length(); i++) {
char ch = text[i];
if(isalpha(ch)) { // ???? ??? ????
letters++;
}
else if(isdigit(ch)) { // ???? ??? ????
digits++;
}
else if(isspace(ch)) { // ?????? ??? ??? ????
spaces++;
}
else { // ????? ?????? ???????
special++;
}
}
// ?? ???? ??????
cout << "????? ???:" << endl;
cout << "?????? ???: " << letters << endl;
cout << "??????? ???: " << digits << endl;
cout << "?????? ???? ???: " << spaces << endl;
cout << "?????? ?????????? ???: " << special << endl;
}
int main() {
analyzeString("Hello World 123 %@#$!");
return 0;
}