Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. #include <fstream>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. ifstream fin("multimi2.in");
  7. ofstream fout("multimi2.out");
  8.  
  9. int p1 , p2, n, m, p, aux;
  10.  
  11. int main () {
  12. fin >> p >> n >> p1 >> m >> p2;
  13. if (p1 > p2)
  14. {
  15. aux = p1;
  16. p1 = p2;
  17. p2 = aux;
  18. aux = n;
  19. n = m;
  20. m = aux;
  21. }
  22.  
  23. if(p == 1)
  24. {
  25. if (p1 + n <= p2)
  26. {
  27. for (int i = p1;i <= n + p1 - 1;i ++)
  28. fout << i << " ";
  29.  
  30. for (int i = p2;i <= m + p2 - 1;i ++)
  31. fout << i << " ";
  32. }
  33. else
  34. if(m + p2 - 1 > n + p1 - 1)
  35. for (int i = p1;i <= m + p2 - 1;i ++)
  36. fout << i << " ";
  37. else
  38. for (int i = p1;i <= n + p1 - 1;i ++)
  39. fout << i << " ";
  40. }
  41. else
  42. {
  43. if (p1 + n - 1 < p2)///mult disj
  44. fout << "-1";
  45. else
  46. if(m + p2 - 1 > n + p1 - 1)
  47. for (int i = p2;i <= p1 + n -1;i ++)
  48. fout << i << " ";
  49. else
  50. for (int i = p2;i <= p2 + m -1;i ++)
  51. fout << i << " ";
  52. }
  53.  
  54. }
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66. #include <fstream>
  67. using namespace std;
  68. ifstream fin("comori1.in");
  69. ofstream fout("comori1.out");
  70. int a[1001], n, i, nr;
  71.  
  72. int main()
  73. {
  74. fin >> n;
  75. for(i = 1; i <= n; i++)
  76. fin >> a[i];
  77. for(i = 2; i <= n; i++)
  78. if(a[i] < a[i-1])
  79. {
  80. fout << i << " ";
  81. nr++;
  82. }
  83. if(nr == 0)
  84. fout<<0<<'\n';
  85.  
  86. fin.close();
  87. fout.close();
  88. return 0;
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement