Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std; // czasami warto z tym uważać
- int main()
- {
- vector<int> liczby;
- int liczba;
- bool z = false;
- cout<<"Wpisuj liczby w osobnych liniach, by zakonczyc wpisz 666"<<endl;
- for(;;)
- {
- z = false;
- cin>>liczba;
- if(liczba == 666)
- break;
- for(int x = 0; x < (int)liczby.size(); x++)
- {
- if(liczby[x] > liczba)
- {
- vector<int>::iterator it;
- it=liczby.begin() + x;
- liczby.insert(it, liczba);
- z = true;
- break;
- }
- }
- if(!z)
- liczby.push_back(liczba);
- }
- for(int x = 0; x < (int)liczby.size(); x++)
- {
- cout<<liczby[x]<<endl;
- }
- cin>>liczba;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment