/* *copyright (C) 2014, Yantai University School of computer *all rights reserved. * File name: Mian.cpp * Author: Han Juan * Date of Completion: November 27, 2014 * Version number: v1.0 * * Problem Description: Create a two-dimensional array, and input 10 numbers by the keyboard, the number of rows in the first output, in the array of numbers multiplied by three, column-first output, Inverted output, output an even number, output all the subscript and I 3 element value * Input Description: Enter 10 number * Program output: The output of the column priority, in the array of numbers multiplied by three, priority output by the columns, inverted output, output the even, output all the subscript and my 3 element value */#include <
;iostream> using namespace std;
int main () {int i,j,t;
Creates an array that assigns the initial value int a[5][4]= {{0,1},{4,5},{8,9},{12,13},{16,17}} to the 10 elements of the first two columns in the array;
Keyboard input after two columns 10 elements of the value cout<< "Please enter 10 integers:" <<endl;
For (i=0, i<=4; ++i) {for (j=2; j<=3; ++j) {cin>>a[i][j];
}}//by row order precedence output cout<< "The value in the array is:" <<endl;
for (i=0; i<=4; ++i) {cout<< "No. <<i<<" line: ";
for (j=0; j<=3; ++j) {cout<<a[i][j]<< ' \ t ';
if (j%3==0&&j!=0) cout<<endl; }}//Multiply all element values by 3 and save in the array cout<< "now multiply all elements by 3 times times ... Complete.
"<<endl; cout<< "line order Priority output:" <<endl;
for (i=0; i<=4; ++i) {cout<< "No. <<i<<" line: ";
for (j=0; j<=3; ++j) {a[i][j]=a[i][j]*3;
cout<<a[i][j]<< ' \ t '; if (j%3==0&&j!=0) cout<<endl; Output by row Order precedence}} cout<< "column order precedence output:" <<endl;//prioritized output by column (see title description) for (i=0;i<4;i++) {cout
<< "<<i<<" column: ";
for (j=0;j<5;j++) {cout<<a[j][i]<< ' \ t ';
} cout<<endl;
} cout<< "Inverted output:" <<endl;
for (i=4; i>=0;-I.) {cout<< "" <<i<< "line:";
for (j=3; j>=0;--j) {cout<<a[i][j]<< ' \ t ';
} cout<<endl;
} cout<< "Array of even:" <<endl; For (i=0, i<=4; ++i) {for (j=0; j<=3; ++j) {if (a[i][j]%2==0) cout<< ;" a["<<I<≪ "]
["<<j<<"]= "<<a[i][j]<<endl;
}} cout<< "column subscript The sum of the elements as multiples of 3:" <<endl; For (i=0, i<=4; ++i) {for (j=0; j<=3; ++j) {if ((i+j)%3==0) cout<< "
a["<<i<<" ["<<j<<"]= "<<a[i][j]<<endl;
}} return 0;
}
Summary of Knowledge points:
This program is a two-dimensional array of integrated applications, two-dimensional array is that our computers are very important for the intestine.
Learning experience · :
For programmers, the application of the two-dimensional array is very important, to practice mastering skills.