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
| #include <iostream>
#include <cstring>
using namespace std;
int main ()
{
char str[201];
cin.getline(str, 201);
int hany_szo = 0;
int hosszok_ossz = 0;
int hany_c = 0;
int maxhossz = 0;
char max_szo[201];
char *p = strtok(str, " ");
while (p != NULL) {
// HF!
int hossz = strlen(p);
hany_szo++;
hosszok_ossz += hossz;
int mgh = 0, msh = 0;
for (int i = 0; p[i] != '\0'; i++) {
if (strchr("aeiou", p[i]) != NULL)
mgh++;
else
msh++;
}
if (mgh > msh)
hany_c++;
if (hossz > maxhossz) {
maxhossz = hossz;
strcpy(max_szo, p);
}
else if (hossz == maxhossz
&& strcmp(p, max_szo) < 0)
{
strcpy(max_szo, p);
}
p = strtok(NULL, " ");
}
cout << "szavak szama: " << hany_szo << endl;
cout << "atlagos hossz: "
<< (double)hosszok_ossz / hany_szo << endl;
cout << "c) " << hany_c << endl;
cout << "maximalis hossz: " << maxhossz << endl;
cout << max_szo << endl;
return 0;
}
|