-
Notifications
You must be signed in to change notification settings - Fork 72
/
Check if a string is Pangrammatic Lipogram
55 lines (44 loc) · 1.16 KB
/
Check if a string is Pangrammatic Lipogram
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
// Javascript program to check if a string
// is Pangrammatic Lipogram
#include<bits/stdc++.h>
using namespace std;
// collection of letters
string alphabets = "abcdefghijklmnopqrstuvwxyz";
// function to check for a Pangrammatic Lipogram
void panLipogramChecker(string s)
{
// convert string to lowercase
for(int i=0; i<s.length(); i++)
{
s[i] = tolower(s[i]);
}
// variable to keep count of all the letters
// not found in the string
int counter = 0 ;
// traverses the string for every
// letter of the alphabet
for(int i=0 ; i<26 ; i++)
{
int pos = s.find(alphabets[i]);
// if character not found in string
// then increment count
if(pos<0 || pos>s.length())
counter += 1;
}
if(counter == 0)
cout<<"Pangram"<<endl;
else if(counter >= 2)
cout<<"Not a pangram but might a lipogram"<<endl;
else
cout<<"Pangrammatic Lipogram"<<endl;
}
// Driver program to test above function
int main()
{
string str = "The quick brown fox jumped over the lazy dog";
panLipogramChecker(str);
str = "The quick brown fox jumps over the lazy dog";
panLipogramChecker(str);
str = "The quick brown fox jum over the lazy dog";
panLipogramChecker(str);
}