ChameL1oN

ОСВход2

Sep 16th, 2015
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void sort(int* &mass, int n)
  6. {
  7. for (int i = n - 1; i > 0; i--)
  8. for (int j = 0; j<i; j++)
  9. {
  10. if (mass[j]>mass[j + 1])
  11. {
  12. int t = mass[j];
  13. mass[j] = mass[j + 1];
  14. mass[j + 1] = t;
  15. }
  16. }
  17. }
  18. void Oo(int* mass, int n)
  19. {
  20. for (int i = 0; i < n; i++)
  21. cout << mass[i]<<" ";
  22. cout << endl;
  23. }
  24. void main()
  25. {
  26. int n, m,n1;
  27. setlocale(LC_ALL, "rus");
  28. cout << "введите количество элементов первого массива ";
  29. cin >> n;
  30. cout << "введите количество элементов второго массива ";
  31. cin >> n1;
  32. int * mass = new int[n];
  33. int *mass2 = new int[n1];
  34. cout << "введите множество " << endl;
  35. for (int i = 0; i < n; i++)
  36. cin>> mass[i];
  37. cout << "введите второе множество" << endl;
  38. for (int j = 0; j < n1; j++)
  39. cin>> mass2[j];
  40. cout << "массив 1" << endl;
  41. Oo(mass, n);
  42. cout << "массив 2" << endl;
  43. Oo(mass2, n1);
  44. sort(mass, n);
  45. sort(mass2, n1);
  46. cout << "массив 1 после сортировки" << endl;
  47. Oo(mass, n);
  48. cout << "массив 2 после сортировки" << endl;
  49. Oo(mass2, n1);
  50. }
Advertisement
Add Comment
Please, Sign In to add comment