SHARE
TWEET

Untitled

a guest Dec 6th, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. vector<int> sortingArray(vector<int> A) {
  7.     int max;
  8.     int csere;
  9.  
  10.     for (int i = 0;i < A.size() - 1; i++){
  11.         max = i;
  12.         for (int j = i + 1; j < A.size(); j++){
  13.             if (A[j] < A[max]){
  14.                 max = j;
  15.             }
  16.         }
  17.         if (i != max ){
  18.             csere = A[i];
  19.             A[i] = A[max];
  20.             A[max] = csere;
  21.         }
  22.     }
  23.     return A;
  24.  
  25. }
  26.  
  27. printArray(vector<int> A) {
  28.     cout << "Rendezett Array:" << endl;
  29.     for (int l = 0; l < A.size(); l++) {
  30.         if(l % 4 == 0 && l != 0){
  31.             cout << endl;
  32.             }
  33.             cout << A[l] << " ";
  34.         }
  35.         cout << endl;
  36. }
  37.  
  38.  
  39. int main()
  40. {
  41.     int tombMeret;
  42.     int a;
  43.     cin >> tombMeret;
  44.     vector<int> tomb;
  45.     while (cin >> a) {
  46.         tomb.push_back(a);
  47.         if (tomb.size() == tombMeret) {
  48.             break;
  49.             }
  50.         }
  51.  
  52.     cout << "Megadott input:" << endl;
  53.     for (int l = 0; l < tomb.size(); l++) {
  54.         if(l % 4 == 0 && l != 0){
  55.             cout << endl;
  56.             }
  57.             cout << tomb[l] << " ";
  58.         }
  59.         cout << endl;
  60.  
  61.     vector<int> sorted;
  62.     sorted = sortingArray(tomb);
  63.     printArray(tomb);
  64.     printArray(sorted)
  65.  
  66. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top