-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCountWord.cpp
More file actions
102 lines (82 loc) · 2 KB
/
CountWord.cpp
File metadata and controls
102 lines (82 loc) · 2 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include <iostream>
#include <cstring>
using namespace std;
void imprimir(int vetc[25], int vetC[25],int vetN[10]){
int ascii = 97;
for(int i=0; i <= 25; i++){
if(vetc[i]!=0){
cout << char(ascii) << ": ";
cout << vetc[i] << " ";
}
ascii++;
}
cout << endl;
ascii = 65;
for(int i=0; i <= 25; i++){
if(vetC[i]!=0){
cout << char(ascii) << ": ";
cout << vetC[i] << " ";
}
ascii++;
}
cout << endl;
ascii = 48;
for(int i=0; i < 10; i++){
if(vetN[i]!=0){
cout << char(ascii) << ": ";
cout << vetN[i] << " ";
}
ascii++;
}
}
void letram(int vetc[25], string name){
int ascii = 97; //minusculo
int tamanho = name.length();
for(int i=0;i<=25;i++){
for(int j=0; j< tamanho;j++){
if(name[j] == ascii) vetc[i]++;
}
ascii++;
}
}
void letraM(int vetC[25], string name){
int ascii = 65;//maiusculo
int tamanho = name.length();
for(int i=0;i<=25;i++){
for(int j=0; j< tamanho;j++){
if(name[j] == ascii) vetC[i]++;
}
ascii++;
}
}
void numero(int vetN[10],string name){
int ascii = 48;
int tamanho = name.length();
for(int i=0;i<=10;i++){
for(int j=0; j< tamanho;j++){
if(name[j] == ascii) vetN[i]++;
}
ascii++;
}
}
int main() {
string name;
int vetC[25] = {0,0,0,0,0,
0,0,0,0,0,
0,0,0,0,0,
0,0,0,0,0,
0,0,0,0,0};
int vetc[25] = {0,0,0,0,0,
0,0,0,0,0,
0,0,0,0,0,
0,0,0,0,0,
0,0,0,0,0};
int vetN[10] = {0,0,0,0,0,
0,0,0,0,0};
getline(cin, name);
numero(vetN,name);
letram(vetc,name);
letraM(vetC,name);
imprimir(vetc,vetC,vetN);
return 0;
}