/ * * @Issue: keyboard input from a plurality of integers (not exceeding 50), which is in the range of 0 to 4, with the input end flag -1, count the number of the same integer * @Author: scholar term * @LastEditTime: 2020-01-18 10:55:28 * / #include <the iostream> the using namespace STD; int main () { int A [50]; // used to store a plurality of integer int num [5] = { 0,0,0,0,0}; // number to represent a value of int T, I = 0; the while (CIN >> T) { IF (T == -. 1) BREAK; a [++ I ] = T; } for (int J = 0; J <I; J ++) {// iterate the several number NUM [A [J]] ++; } for (int J = 0; J <. 5; J ++) { COUT << "NUM [" J << << "] =" << NUM [J] << endl; } return 0; }
/* * @Issue: 若说明int a[2][3]={{1,2,3},{4,5,6}},将行和列的元素互换 * @Author: 一届书生 * @LastEditTime : 2020-01-18 11:01:46 */ #include<iostream> using namespace std; int main(){ int a[2][3]={{1,2,3},{4,5,6}}; int b[3][2]; for(int i=0;i<2;i++){ for(int j=0;j<3;j++){ b[j][i]=a[i][j]; } } for(int i=0;i<3;i++){ for(int j=0;j<2;j++) cout<<b[i][j]<<"\t"; cout<<endl; } return 0; }
/ * * @Issue: a defined integer array containing thirty elements, respectively, in order to impart an even number from 2 to begin, and in order to obtain a mean value for each of the five values * and output on another array * @ author: scholar term * @LastEditTime: 2020-01-18 11:23:09 * / #include <the iostream> the using namespace STD; int main () { int A [30], B [. 6] = {0,0 , 0,0,0,0}, SUM = 0; for (int I = 2, J = 0; J <30; I + = 2) {// do to a array a [J ++] = I; } / / I think he finally wanted to this method, each of the five takes, and for (int I = 0; I <30/5; I ++) { for (int. 5 J = I *; J <* I +. 5. 5; J ++) { B [I] = A + [J]; } } for (int I = 0; I <. 6; I ++) COUT << B [I] /. 5 << endl; return 0; }
/ * * @Issue: line-sequentially by the circulation of a 5 * 5 two-dimensional array forming a natural number of 1 to 25, and then outputs the lower-left triangular array * @Author: next scholar * @LastEditTime: 2020-01- 11:28:45 18 is * / #include <the iostream> the using namespace STD; int main () { int A [. 5] [. 5]; for (int I = 0; I <. 5; I ++) for (int = 0 J ; J <. 5; J ++) CIN >> A [I] [J]; for (int I = 0; I <. 5; I ++) { for (int J = 0; J <= I; J ++) { COUT << A [I] [J] << ""; } COUT << endl; } return 0; }