14th Week Item 1 tossing two-dimensional arrays

Source: Internet
Author: User
Tags arrays
/* *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 &lt
;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<&lt ;" a["&LT;&LT;I&LT;&Lt; "]
        ["<<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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.