#include<iostream>usingnamespace std;intmain(){int a[5][3]={5,7,6,1,2,5,11,1,9,6,3,17,0,3,4};int b[5]={0};int c =0, d =0, e =0;for(int i =0; i <5; i++){for(int j =0; j <3; j++) c += a[i][j];
b[i]+= c;
c =0;}for(int i =1; i <5; i++){if(b[i]> b[i -1]) d = b[i];else d = b[i -1];}for(int i =0; i <5; i++)if(d == b[i]) e = i;for(int j =0; j <3; j++) cout << a[e][j]<<'\t';
cout << endl;for(int i =1; i <5; i++){if(i == e){for(int j =0; j <3; j++) cout << a[0][j]<<'\t';
cout << endl;}else{for(int j =0; j <3; j++) cout << a[i][j]<<'\t';
cout << endl;}}return0;}
#include<iostream>usingnamespace std;intmain(){int a[4][4]={7,21,4,6,18,12,9,11,4,23,6,15,3,7,6,2};int(*p)[4]= a;int b =0, c =0, d =3, e =0, f =0, g =0;for(int i =0; i <4; i++){for(; b <4; b++) c +=*(*(p + i)+ b);
b += i -3;}
cout <<"上三角所有元素的和为"<< c << endl;for(int i =0; i <4; i++){for(; d <4; d++){
e +=*(*(p + i)+ f);
f++;}
d -= i +2;
f =0;if(d <0)break;}
cout <<"下三角所有元素和为"<< e << endl;for(int i =0, j =0; i <4; i++, j++) g +=*(*(p + i)+ j);
cout <<"主对角线上的所有元素和为"<< g << endl;return0;}
#include<iostream>#include<string>usingnamespace std;intmain(){
string a;
cout <<"Please input one sentence : ";getline(cin, a);int b =0, c =0, d =1;
b = a.length();for(int i =0; i <b; i++){if(a[i]=='A') a[i]='a';if(a[i]=='B') a[i]='b';if(a[i]=='C') a[i]='c';if(a[i]=='D') a[i]='d';if(a[i]=='E') a[i]='e';if(a[i]=='F') a[i]='f';if(a[i]=='G') a[i]='g';if(a[i]=='H') a[i]='h';if(a[i]=='I') a[i]='i';if(a[i]=='J') a[i]='j';if(a[i]=='K') a[i]='k';if(a[i]=='L') a[i]='l';if(a[i]=='M') a[i]='m';if(a[i]=='N') a[i]='n';if(a[i]=='O') a[i]='o';if(a[i]=='P') a[i]='p';if(a[i]=='Q') a[i]='q';if(a[i]=='R') a[i]='r';if(a[i]=='S') a[i]='s';if(a[i]=='T') a[i]='t';if(a[i]=='U') a[i]='u';if(a[i]=='V') a[i]='v';if(a[i]=='W') a[i]='w';if(a[i]=='X') a[i]='x';if(a[i]=='Y') a[i]='y';if(a[i]=='Z') a[i]='z';if(a[i]!='a'&& a[i]!='b'&& a[i]!='c'&& a[i]!='d'&& a[i]!='e'&& a[i]!='f'&& a[i]!='g'&& a[i]!='h'&& a[i]!='i'&& a[i]!='j'&& a[i]!='k'&& a[i]!='l'&& a[i]!='m'&& a[i]!='n'&& a[i]!='o'&& a[i]!='p'&& a[i]!='q'&& a[i]!='r'&& a[i]!='s'&& a[i]!='t'&& a[i]!='u'&& a[i]!='v'&& a[i]!='w'&& a[i]!='x'&& a[i]!='y'&& a[i]!='z'){
a.erase(i,1);
i--;
b--;}}
c = a.length();for(int i =0; i < c /2; i++){if(a[i]!= a[c -1- i]){
d =0;break;}}if(d) cout <<"The string is a palindrome.";else cout <<" The string is not a palindrome.";return0;}
#include<iostream>#include<vector>#include<cstdlib>usingnamespace std;intmain(){srand(1);
cout <<"Please input your lucky number: ";int n =0, m =0, d =0, e =0;
cin >> n;
vector<int>a(n,0);for(int i =1; i <= n; i++) a[i -1]= i;
m =1+rand()% n;for(int i =0; i < n; i++){
d++;if(d == m){
a.erase(a.begin()+i);
i--;
d =0;}if(i == a.size()-1) i =-1;if(a.size()==1)break;}
cout <<"It turns out to be "<< a[0]<< endl;return0;}