forked from sitz/UVa-Online-Judge
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path10761.cpp
86 lines (82 loc) · 1.7 KB
/
10761.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
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
#include <bits/stdc++.h>
using namespace std;
string broken;
bool has_or_not(char x)
{
for (unsigned int i = 0; i < broken.length(); i++)
{
if (tolower(broken.at(i)) == x)
{
return true;
}
}
return false;
}
int main()
{
int keyboard = 0;
cout << "+----------+----------------+-----------------------------+" << endl;
cout << "| Keyboard | # of printable | Additionally, the following |" << endl;
cout << "| | lines | letter keys can be broken |" << endl;
cout << "+----------+----------------+-----------------------------+" << endl;
while (cin >> broken && broken != "finish")
{
getchar();
string text;
int printable_lines = 0;
int small_letters[28];
for (int i = 0; i < 28; i++)
{
small_letters[i] = 0;
}
for (unsigned int i = 0; i < broken.length(); i++)
{
if (isalpha(broken.at(i)))
{
small_letters[tolower(broken.at(i)) - 'a'] = 1;
}
}
do
{
getline(cin, text);
bool flag = true;
for (unsigned int i = 0; i < text.length(); i++)
{
if (has_or_not(tolower(text.at(i))))
{
flag = false;
break;
}
}
if (flag)
{
printable_lines++;
for (unsigned int i = 0; i < text.length(); i++)
{
if (isalpha(text.at(i)))
{
small_letters[tolower(text.at(i)) - 'a'] = 1;
}
}
}
} while (text != "END");
int space = 0;
printf("| %3d | %3d | ", ++keyboard, printable_lines++);
for (int i = 0; i < 26; i++)
{
if (small_letters[i] == 0)
{
printf("%c", i + 'a');
space++;
}
}
while (28 - space)
{
printf(" ");
space++;
}
printf("|\n");
cout << "+----------+----------------+-----------------------------+" << endl;
}
return 0;
}