Quick actions

cmd+k|ctrl+k

Navigation

Languages

lab6 (38)

Snippet info

Language

Cpp

Visibility

public

Author

andrusus.korotkovus

Created

2018-12-20T23:42:05Z

Updated

2018-12-20T23:42:05Z

#include <iostream>

using namespace std;

int main()
{
    setlocale(LC_ALL, "ru");
	int const N = 10;
	int array[N]; 

	for (int i = 0; i < N; i++)
	{
		array[i] = rand() % 10;
	}
	for (int i = 0; i < N; i++)
	{
		cout << i << ". " << array[i] << endl;
	}

	cout << endl << "Результат:" << endl;

	for (int i = 0; i < N; i+=2)
	{
		swap(array[i], array[i + 1]);
	}

	for (int i = 0; i < N; i++)
	{
		cout << i << ". " << array[i] << endl;
	}

	return 0;
}
INFO