fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <map>
  4. #include <vector>
  5.  
  6. using namespace std;
  7.  
  8. int main() {
  9. string str, word = "", max = "";
  10. vector<int> alph(26, 0);
  11. int count = 0;
  12. getline(cin, str);
  13.  
  14. bool flag = false;
  15. for (int i = 0; i < str.size(); i++) {
  16. if (str[i] == ' ') {
  17. if (flag) {
  18. count++;
  19. flag = false;
  20. }
  21. if (word.size() > max.size()) {
  22. max = word;
  23. word = "";
  24. }
  25. }
  26. else {
  27. flag = true;
  28. alph[str[i] - 'a']++;
  29. word += str[i];
  30. }
  31.  
  32. }
  33. if (flag) {
  34. count++;
  35. flag = false;
  36. }
  37. if (word.size() > max.size()) {
  38. max = word;
  39. word = "";
  40. }
  41.  
  42. int m = 0;
  43.  
  44. for (int i = 0; i < alph.size(); i++) {
  45. if (alph[i] > m) {
  46. m = alph[i];
  47. }
  48. }
  49.  
  50. flag = false;
  51. for (int i = 0; i < alph.size(); i++) {
  52. if (alph[i] == m) {
  53. if (flag) {
  54. cout << ' ' << (char)(i + 'a');
  55. }
  56. else {
  57. cout << (char)(i + 'a');
  58. flag = true;
  59. }
  60. }
  61. }
  62. cout << endl;
  63. flag = false;
  64. for (int i = 0; i < alph.size(); i++) {
  65. if (alph[i] == 0) {
  66. if (flag) {
  67. cout << ' ' << (char)(i + 'a');
  68. }
  69. else {
  70. cout << (char)(i + 'a');
  71. flag = true;
  72. }
  73. }
  74. }
  75. cout << endl << count << endl << max;
  76.  
  77. return 0;
  78. }
Success #stdin #stdout 0.01s 5544KB
stdin
Standard input is empty
stdout
a b c d e f g h i j k l m n o p q r s t u v w x y z
a b c d e f g h i j k l m n o p q r s t u v w x y z
0