14th Week Project One (4)--toss a two-dimensional array

Source: Internet
Author: User

/* Copyright (c) 2014, Yantai University School of Computer * All rights reserved. * File name: Test.cpp * Chen Dani * Completion date: November 30, 2014 * Version number: v1.0 * * Problem Description: No * Input Description: Enter some integer * program output: Output two-dimensional array */#include <iostre    Am>using namespace Std;int main () {int i,j;    Creates a two-dimensional integer array of 5 rows and 4 columns, assigning 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;    The keyboard input causes the value of the latter two columns 10 elements cout<< "Please enter 10 integers:" <<endl;    for (i=0; i<5; i++)//i line for (j=2; j<4; j + +)//j column cin>>a[i][j];    The number in the cout<< "array by row order precedence output is:" <<endl;        for (i=0; i<5; i++) {cout<< "No. <<i<<" line: ";        for (j=0; j<4; j + +) cout<<a[i][j]<< ' \ t ';    cout<<endl; }//Multiply all element values by 3 and save in the array cout<< "Now multiply all the elements by 3 times times ... Complete!    "<<endl;    cout<< "line order Priority output:" <<endl;        for (i=0; i<5; i++) {cout<< "No. <<i<<" line: ";        for (j=0; j<4; j + +) cout<<3*a[i][j]<< ' \ t ';    cout<<endl; }//By columnPriority output (the first row of the output is the first column in the array row ...), in fact the output is "transpose") cout<< "sequencing priority output:" <<endl;   for (i=0; i<4; i++) {cout<< "<<i<<" column: ";        I column for (j=0; j<5; j + +)//j line cout<<3*a[j][i]<< ' \ t ';    cout<<endl;    }//The array is "inverted" to output (that is, the first output of the last column of the last row, the last output of the No. 0 column of row No. 0) cout<< "inverted output:" <<endl;        for (i=4; i>=0; i--) {cout<< "No. <<i<<" line: ";        for (j=3; j>=0; j--) cout<<a[i][j]<< ' \ t ';    cout<<endl; } return 0;}

14th Week Project One (4)--toss a two-dimensional array

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.