Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int main()
- {
- int meret;
- int a;
- cin >> meret;
- vector<int> tomb;
- while (cin >> a) {
- tomb.push_back(a);
- if (tomb.size() == meret) {
- break;
- }
- }
- //Input kiírása
- cout << "Input:" << endl;
- for (int i = 0; i < meret; i++) {
- if(i%5==0 && i!=0){
- cout << endl;
- }
- cout << tomb[i] << " ";
- }
- cout << endl << endl;
- //rendezés
- int csere;
- for( int i = 0; i < meret-1; i++ )
- {
- for( int j = i+1; j < meret; j++ )
- {
- if( tomb[i] > tomb[j] )
- {
- csere = tomb[i];
- tomb[i] = tomb[j];
- tomb[j] = csere;
- }
- }
- }
- //Output kiírása
- cout << "Output:" << endl;
- for (int i = 0; i < meret; i++) {
- if(i%5==0 && i!=0){
- cout << endl;
- }
- cout << tomb[i] << " ";
- }
- cout << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement