If a sentence contains all the letters, It is called pangrams. For example:
"A quick brown fox Jumps over
The lazy dog "is a pangrams.
Write a C ++ function, string getmissingletters (const string &
SA)
Sa represents an input sentence.
If SA is not pangrams, the function should output all letters missing from SA. The output letters should be alphabetically arranged.
BTW:
Uppercase and lowercase letters are output.
# Include <iostream> <br/> # include <string> <br/> using namespace STD; <br/> string getmissingletters (const string & SA ); <br/> int _ tmain (INT argc, _ tchar * argv []) <br/>{</P> <p> // string strsentence = "jumps over the lazy dog"; <br/> string strsentence = ""; <br/> string missingletters = getmissingletters (strsentence); <br/> cout <missingletters <Endl; <br/> return 0; <br/>}< br/> string getmissingletters (const string & SA) <br/>{< br/> int letterfre [256] = {0 }; <br/> int occurletternum = 0; <br/> for (INT I = 0; I <SA. size (); I ++) <br/>{< br/> char CH = sa [I]; <br/> // if it is a capital letter, convert it to lower case <br/> If (CH> = 'A' & Ch <= 'Z ') <br/>{< br/> CH = 'A' + (CH-'A '); <br/>}< br/> // If (CH <'A' | ch> 'Z ') <br/>{< br/> continue; <br/>}< br/> // count the number of letters that have occurred <br/> If (letterfre [(INT) ch] = 0) <br/>{< br/> occurletternum ++; <br/>}< br/> letterfre [(INT) CH] ++; <br/>}< br/> // Of course, 26-occurletternum is not displayed. <br/> string missletters (26-occurletternum ,''); </P> <p> // extract unused letters <br/> int COUNT = 0; <br/> for (INT I = 'a '; I <= 'Z'; I ++) <br/>{< br/> If (letterfre [I] = 0) <br/>{< br/> missletters [count ++] = (char) I; <br/>}< br/> return missletters; <br/>}