-
Notifications
You must be signed in to change notification settings - Fork 7
/
Panagram
46 lines (37 loc) · 1006 Bytes
/
Panagram
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
#include<bits/stdc++.h>
using namespace std;
bool checkPangram (string &str)
{
vector<bool> mark(26, false);
int index;
for (int i=0; i<str.length(); i++)
{
// If uppercase character, subtract 'A'
// to find index.
if ('A' <= str[i] && str[i] <= 'Z')
index = str[i] - 'A';
// If lowercase character, subtract 'a'
// to find index.
else if('a' <= str[i] && str[i] <= 'z')
index = str[i] - 'a';
// Mark current character
mark[index] = true;
}
// Return false if any character is unmarked
for (int i=0; i<=25; i++)
if (mark[i] == false)
return (false);
// If all characters were present
return (true);
}
// Driver Program to test above functions
int main()
{
string str;
cin>>str;
if (checkPangram(str) == true)
printf (""%s" is a pangram", str.c_str());
else
printf (""%s" is not a pangram", str.c_str());
return(0);
}