fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int n, d = 0;
  6. cin >> n;
  7. cin.ignore();
  8.  
  9. vector<int> tab(n);
  10. for (int i = 0; i < n; i++) {
  11. cin >> tab[i];
  12. }
  13. cin.ignore();
  14. string k;
  15. getline(cin, k);
  16. vector<string> words;
  17. string c;
  18. for (char ch : k) {
  19. if (isalpha(ch)) {
  20. c += ch;
  21. } else {
  22. if (!c.empty()) {
  23. words.push_back(c);
  24. c.clear();
  25. }
  26. }
  27. }
  28. if (!c.empty()) words.push_back(c);
  29. for (int i=0; i<n; i++) {
  30. if (tab[i]==1) {
  31. int liczbaa = 0;
  32. for (char znak : k) {
  33. if (isspace(znak))
  34. {
  35. liczbaa++;
  36. }
  37. }
  38. cout<<liczbaa;
  39. } else if (tab[i] == 2) {
  40. int liczba=0;
  41. if(k[0]>='0' && k[0]<='9')
  42. {
  43. liczba++;
  44. }
  45. for(int i=1; i<k.size(); i++)
  46. {
  47. if(k[i]>='0' && k[i]<='9' && (k[i-1]<'0' || k[i-1]>'9'))
  48. {
  49. liczba++;
  50. }
  51. }
  52. cout<<liczba;
  53. } else if (tab[i] == 3) {
  54. cout<<words.size();
  55. } else if (tab[i] == 4) {
  56. int z=0;
  57. bool oski=true;
  58. for(int i=0; i<k.size(); i++)
  59. {
  60. if(oski && k[i]=='.')
  61. {
  62. z++;
  63. oski = false;
  64. }
  65. else if(isalpha(k[i]))
  66. {
  67. oski = true;
  68. }
  69. }
  70. cout<<z;
  71. } else if (tab[i] == 5) {
  72. for (const string& word : words) {
  73. bool bajtek = true;
  74. int a = word.size();
  75. for (int j = 0; j < a; j++) {
  76. if (word[j] != word[a - j - 1] && word[j]-32 != word[a - j - 1] && word[j] != word[a - j - 1]-32) {
  77. bajtek = false;
  78. break;
  79. }
  80. }
  81. if (bajtek){
  82. d++;
  83. }
  84. }
  85. cout << d;
  86. cout<<" ";
  87. }
  88. cout<<endl;
  89. }
  90. return 0;
  91. }
  92.  
Success #stdin #stdout 0.01s 5288KB
stdin
5
2 4 1 3 5
domEk  K5k45. aLA.
stdout
2
2
3
4
3