-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathpangrams.cpp
More file actions
54 lines (44 loc) · 861 Bytes
/
pangrams.cpp
File metadata and controls
54 lines (44 loc) · 861 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
54
#include<iostream>
#include<stdio.h>
#include<string>
using namespace std;
int main(){
string str;
getline(cin,str);
string new_str = "";
int hash1[26] = {0};
int hash2[26] = {0};
string small ="abcdefghijklmnopqrstuvwxyz";
string capital = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
//hash small
for(int i=0;i<small.length();i++){
if(new_str[i]>=97)
small[small[i]- 'a']++;
else
capital[capital[i]- 'A']++;
}
//remove space from string
for(int i=0;i<str.length();i++){
if(str[i]==' ')
continue;
else
new_str+=str[i];
}
//hashing new string
int hash_new[26] ={0};
for(int i=0;i<new_str.length();i++){
if(new_str[i]>=97)
hash_new[new_str[i]- 'a']++;
else
hash_new[new_str[i]- 'A']++;
}
int count=0;
for(int i=0;i<26;i++){
if(hash_new[i]>0)
count++;
}
if(count==26)
cout<<"pangram";
else
cout<<"not pangram";
}