#include <iostream>
#include <math.h>
using namespace std;
#define N 9
int main()
{ int a[N],b;
for (int i = 0; i < N; i++) a[i] = rand() % 10;
for (int i=0; i < N; i++) cout << a[i]<<" ";
cout << "\n";
//
// Input here your code
//
// Inputted code:
for (int i = 0; i < N-1; i = i + 2)
{
b = a[i];
a[i] = a[i + 1];
a[i + 1] = b;
}
//
for (int i=0; i < N; i++) cout << a[i] << " ";
cout << "\n";
}
#include <math.h>
using namespace std;
#define N 9
int main()
{ int a[N],b;
for (int i = 0; i < N; i++) a[i] = rand() % 10;
for (int i=0; i < N; i++) cout << a[i]<<" ";
cout << "\n";
//
// Input here your code
//
// Inputted code:
for (int i = 0; i < N-1; i = i + 2)
{
b = a[i];
a[i] = a[i + 1];
a[i + 1] = b;
}
//
for (int i=0; i < N; i++) cout << a[i] << " ";
cout << "\n";
}
No comments:
Post a Comment