Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- using namespace std;
- int main() {
- srand(time(0));
- setlocale(LC_ALL, "");
- int a;
- cout << "Введите размер массива : ";
- cin >> a;
- int *mas = new int [a];
- cout << "Введите массив : " << endl;
- for (int i = 0; i < a; i++) {
- mas[i]= (-20+rand() %100);
- }
- for (int i = 0; i < a; i++) {
- cout << mas[i] << " ";
- }
- cout << endl;
- for (int i = 0; i < a; i++) {
- for (int p = 0; p < a; p++) {
- if (mas[p] < mas[i] && mas[i]>0 && mas[p]>0) {
- int temp = 0;
- temp = mas[p];
- mas[p] = mas[i];
- mas[i] = temp;
- }
- }
- }
- for (int i = 0; i < a; i++) {
- cout << mas[i]<< " ";
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment