Advertisement
HeroBaga

Untitled

Oct 10th, 2021
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. ifstream input;
  8. ofstream output;
  9. input.open("input.txt");
  10. output.open("output.txt");
  11. int number;
  12. input >> number;
  13. for (int i = 0; i < number; i++) {
  14. int len;
  15. input >> len;
  16. int *buf = new int[len];
  17. input >> buf[0];
  18. int exp_id = 0;
  19. int max_id = 0;
  20. int raz_id = len - 1;
  21. bool flag = true;
  22. int j;
  23. for (j = 1; j < len; j++) {
  24. input >> buf[j];
  25. if ((buf[exp_id] == buf[j]) && (j - exp_id == 1)) {
  26. exp_id = j;
  27. }
  28. if (buf[j] != buf[exp_id]) {
  29. if (buf[max_id] < buf[j]) {
  30. max_id = j;
  31. }
  32. }
  33. }
  34. for (j = len - 1; j > max_id; j--) {
  35. if ((buf[raz_id] == buf[j]) && (raz_id - j == 1)) {
  36. raz_id = j;
  37. }
  38. }
  39. for (j = exp_id + 1; j < max_id; j++) {
  40. if (buf[j] >= buf[j + 1]) {
  41. output << "Nein1";
  42. flag = false;
  43. break;
  44. }
  45. }
  46. if (exp_id + 1 == len) {
  47. output << "Nein2";
  48. flag = false;
  49. }
  50. if (j == max_id) {
  51. for (j = raz_id; j > max_id; j--) {
  52. if (buf[j] >= buf[j - 1]) {
  53. output << "Nein3";
  54. flag = false;
  55. break;
  56. }
  57. }
  58. }
  59. if (flag) {
  60. output << "Freytag " << exp_id + 1 << " " << max_id + 1 << " " << raz_id + 1;
  61. }
  62. output << endl;
  63. delete[] buf;
  64.  
  65. }
  66. return 0;
  67. }
  68.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement