Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Массив длинной 1000 чисел. Выводится, сортируется, снова выводится.
- #include <iostream>
- #include <cstdlib>
- using namespace std;
- int main()
- {
- srand(time(NULL))
- int m[1000], i;
- for (i=0; i<=999; i++)
- m[i]=rand();
- outmass (m, 1000);
- sortmass (m, 1000);
- outmass (m, 1000);
- cin.sync();
- cin.clar();
- cin.get();
- return 0;
- }
- void outmass(int massiv[], int save)
- {
- for (int i=0; i<save; i++)
- cout<<massiv[i];
- }
- void sortmass(int massiv[], int save)
- {
- for (int f=0; f<save; f++)
- for (int t=0; t<=save-f; t++)
- if (massiv [t]>massiv[t+1]
- zam (massiv [t], massiv [t+1]);
- }
- void zam (int &a, int &b)
- {
- int x;
- x = a;
- a = b;
- b = x;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement