Max_Leb

F2

Feb 2nd, 2022 (edited)
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. #include <fstream>
  2.  
  3. #define LENGTH 300
  4.  
  5. int dif(char p){
  6. if (p == 'a' || p == 'e' || p == 'i' || p == 'o' || p == 'u' || p == 'y')
  7. return 1;
  8. return 0;
  9. }
  10.  
  11. int length(char a[][LENGTH], int line){
  12. int cnt;
  13. for (cnt = 0; a[line][cnt] != '\0'; ++cnt);
  14. return cnt;
  15. }
  16.  
  17. using namespace std;
  18.  
  19. int main() {
  20. ifstream fin("input.txt");
  21. ofstream fout("output.txt");
  22. int N;
  23. fin >> N;
  24. char word[N][LENGTH];
  25. int cnt[N];
  26. for (int i = 0; i < N; ++i)
  27. cnt[i] = 0;
  28.  
  29. int maxx = 0;
  30. for (int i = 0; i < N; ++i) {
  31. fin >> word[i];
  32. int len = length(word, i);
  33. word[i][len + 1] = '0';
  34. word[i][len + 2] = '\0';
  35.  
  36. for (int j = len; j > 0; --j)
  37. word[i][j] = word[i][j-1];
  38. word[i][0] = '0';
  39.  
  40. for (int j = 3; j < len + 2; ++j) {
  41. if (!dif(word[i][j]) && !dif(word[i][j-3]) && dif(word[i][j-1]) && dif(word[i][j-2])){
  42. cnt[i]++;
  43. }
  44. }
  45. maxx = cnt[i] > maxx ? cnt[i] : maxx;
  46. }
  47.  
  48. for (int i = 0; i < N; ++i) {
  49. if (cnt[i] == maxx) {
  50. for (int j = 1; word[i][j]; ++j) {
  51. if (word[i][j] != '0'){
  52. fout << word[i][j];
  53. }
  54. }
  55. fout << endl;
  56. }
  57. }
  58.  
  59. fin.close();
  60. fout.close();
  61.  
  62. return 0;
  63. }
  64.  
Add Comment
Please, Sign In to add comment