Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Ðàáîòó âûïîëíèë ñòóäåíò 1-ãî êóðñà ÁÁÁÎ-03-19 Ãàâðèëîâ Ìàòâåé Äìèòðèåâè÷
- // Âàðèàíò 0
- #include <iostream>
- using namespace std;
- int main()
- {
- setlocale(LC_ALL,"rus");
- const int MAX = 100;
- int num;
- int arr[MAX], temp[MAX];
- cout << "Ââåäèòå ðàçìåð ìàññèâà (ðàçìåð äîëæåí áûòü íå áîëüøå " << MAX << "): ";
- cin >> num;
- for (int i=0; i<num; i++)
- {
- cout << "Ââåäèòå " << i+1 << " ýëåìåíò ìàññèâà: ";
- cin >> arr[i];
- temp[i] = arr[i];
- }
- for (int i=0; i< num; i++)
- {
- for (int j=0; j<num; j++ )
- {
- int buf;
- if (temp[j] < temp[j+1])
- {
- buf = temp[j];
- temp[j] = temp[j+1];
- temp[j+1]=buf;
- }
- }
- }
- cout << endl;
- for (int i=0; i<num; i++)
- {
- cout << arr[i] << " ";
- }
- cout << endl;
- int count = 0;
- int tret = 0;
- for (int i=num; i>0; i--)
- {
- if (temp[i-1] != temp[i])
- {
- count++;
- if (count == 3)
- tret = temp[i-1];
- }
- }
- if (tret != 0)
- {
- cout << "3-å ïî âåëè÷èíå ÷èñëî: " << tret << endl;
- cout << endl << "Ïðåîáðàçîâàííûé ìàññèâ: "<< endl;
- for (int i=0; i<num; i++)
- {
- if (arr[i] > tret)
- arr[i] = tret;
- cout << arr[i] << " ";
- }
- cout << endl;
- }
- else
- {
- cout << " äàííîì ìàññèâå ïðèñóòñòâóåò òîëüêî äâà ÷èñëà! Ââåäèòå åùå ðàç." << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement