fork(1) download
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. char s[256];
  8. int maxPalNum = 0;
  9. int champion = 0;
  10. int currentSentence = 1;
  11. int palCount = 0;
  12. while (cin >> s)
  13. {
  14. if (s[0] == '-' && strlen(s) == 1)
  15. continue;
  16. bool endOfSentence = false;
  17. if (s[strlen(s)-1] == '.' || s[strlen(s)-1] == '!' || s[strlen(s)-1] == '?')
  18. endOfSentence = true;
  19. for (int i = strlen(s) - 1; i >= 0; i--)
  20. {
  21. if (!(s[i] >= 'a' && s[i] <= 'z' || s[i] >= 'A' && s[i] <= 'Z' || s[i] >= '1' && s[i] <= '9' || s[i] == '-'))
  22. s[i] = '\0';
  23. else
  24. break;
  25. }
  26. bool pal = true;
  27.  
  28. for (int i = 0; i < strlen(s) / 2; i++)
  29. {
  30. if (s[i] >= 'A' && s[i] <= 'Z')
  31. s[i] += 32;
  32. if (s[strlen(s)-i-1] >= 'A' && s[strlen(s)-i-1] <= 'Z')
  33. s[strlen(s)-i-1] += 32;
  34. if (s[i] != s[strlen(s)-i-1])
  35. {
  36. pal = false;
  37. break;
  38. }
  39. }
  40. if (pal)
  41. palCount ++;
  42. if (endOfSentence)
  43. {
  44. if (palCount > maxPalNum)
  45. {
  46. maxPalNum = palCount;
  47. champion = currentSentence;
  48. }
  49. currentSentence++;
  50. palCount = 0;
  51. }
  52. }
  53. cout << champion;
  54. return 0;
  55. }
Success #stdin #stdout 0s 3460KB
stdin
Ai'iA - a-a-a? Oho hoh.
stdout
Standard output is empty