-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathisogram.cpp
More file actions
53 lines (40 loc) · 932 Bytes
/
isogram.cpp
File metadata and controls
53 lines (40 loc) · 932 Bytes
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
// NOTE: it is recommended to use this even if you don't understand the following code.
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
// input data
int N;
string S;
int main() {
// uncomment the following lines if you want to read/write from files
ifstream cin("input.txt");
ofstream cout("output.txt");
cin >> N;
cin.ignore();
int isogram = 0;
for (int test=0; test<N; test++) {
getline(cin, S);
// insert your code here
for (int i=0; i<S.size(); i++) {
if (S[i]>=65 && S[i]<= 90 || S[i]>=97 && S[i]<= 122) {
S[i] = toupper(S[i]);
}
}
bool iso = true;
for (int i=65; i<=90; i++) {
int num = count(S.begin(), S.end(), (char) i);
if (num > 2) {
iso = false;
break;
}
}
if (iso) {
isogram ++;
}
}
cout << isogram << endl; // print the result
return 0;
}