Advertisement
Guest User

Untitled

a guest
Nov 15th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. // Ðàáîòó âûïîëíèë ñòóäåíò 1-ãî êóðñà ÁÁÁÎ-03-19 Ãàâðèëîâ Ìàòâåé Äìèòðèåâè÷
  2. // Âàðèàíò 0
  3.  
  4. #include <iostream>
  5. using namespace std;
  6. int main()
  7. {
  8. setlocale(LC_ALL,"rus");
  9. const int MAX = 100;
  10. int num;
  11. int arr[MAX], temp[MAX];
  12. cout << "Ââåäèòå ðàçìåð ìàññèâà (ðàçìåð äîëæåí áûòü íå áîëüøå " << MAX << "): ";
  13. cin >> num;
  14. for (int i=0; i<num; i++)
  15. {
  16. cout << "Ââåäèòå " << i+1 << " ýëåìåíò ìàññèâà: ";
  17. cin >> arr[i];
  18. temp[i] = arr[i];
  19. }
  20.  
  21. for (int i=0; i< num; i++)
  22. {
  23. for (int j=0; j<num; j++ )
  24. {
  25. int buf;
  26. if (temp[j] < temp[j+1])
  27. {
  28. buf = temp[j];
  29. temp[j] = temp[j+1];
  30. temp[j+1]=buf;
  31. }
  32. }
  33.  
  34. }
  35.  
  36. cout << endl;
  37. for (int i=0; i<num; i++)
  38. {
  39. cout << arr[i] << " ";
  40. }
  41. cout << endl;
  42.  
  43. int count = 0;
  44. int tret = 0;
  45. for (int i=num; i>0; i--)
  46. {
  47. if (temp[i-1] != temp[i])
  48. {
  49. count++;
  50. if (count == 3)
  51. tret = temp[i-1];
  52. }
  53. }
  54. if (tret != 0)
  55. {
  56. cout << "3-å ïî âåëè÷èíå ÷èñëî: " << tret << endl;
  57. cout << endl << "Ïðåîáðàçîâàííûé ìàññèâ: "<< endl;
  58. for (int i=0; i<num; i++)
  59. {
  60. if (arr[i] > tret)
  61. arr[i] = tret;
  62. cout << arr[i] << " ";
  63. }
  64. cout << endl;
  65. }
  66. else
  67. {
  68. cout << " äàííîì ìàññèâå ïðèñóòñòâóåò òîëüêî äâà ÷èñëà! Ââåäèòå åùå ðàç." << endl;
  69. }
  70.  
  71. return 0;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement