fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. bool pangram(std::string s)
  5. {
  6. int letters = 0;
  7. for (std::string::iterator it = s.begin(); it != s.end(); ++it)
  8. {
  9. int ltr = (*it | 32) - 97;
  10. if ((unsigned)ltr < 26) letters |= (1 << ltr);
  11. }
  12. //std::cout << std::hex << letters << std::endl;
  13. return letters == 0b11111111111111111111111111; // all 26 (0x3ffffff)
  14. }
  15.  
  16. int main()
  17. {
  18. std::string s;
  19. std::cout << "enter a sentence, to find out whether it is a pangram (all letters):";
  20. std::getline(std::cin, s);
  21. std::cout << (pangram(s) ? "yup" : "nope") << std::endl;
  22. return 0;
  23. }
  24.  
Success #stdin #stdout 0.01s 5512KB
stdin
Pack my box with five dozen liquor jugs
stdout
enter a sentence, to find out whether it is a pangram (all letters):3ffffff
yup