Advertisement
HeroBaga

Untitled

Oct 10th, 2021
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 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; j < max_id; j++) {
  40. if (buf[j] >= buf[j + 1]) {
  41. output << "Nein";
  42. flag = false;
  43. break;
  44. }
  45. }
  46. if (j == max_id) {
  47. for (j = raz_id; j > max_id; j--) {
  48. if (buf[j] >= buf[j - 1]) {
  49. output << "Nein";
  50. flag = false;
  51. break;
  52. }
  53. }
  54. }
  55. if (exp_id + 1 == len ||exp_id > max_id || max_id > raz_id || max_id == raz_id || exp_id == max_id || exp_id > raz_id) {
  56. output << "Nein";
  57. flag = false;
  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. return 0;
  66. }
  67.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement