1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
//cout<<setprecision(2)<<left<<endl;
cout<<setw(15)<<"A"<<setw(20)<<"B"<<endl;
const int sz=4;
int A[sz][sz]={{10,15,20,25}, {100,200,300,400},{1,2,3,4},{5,6,7,8}};
int B[sz][sz],i,c,j;
int *ptra= &A[0][0];
int *ptrb= &B[0][0];
for ( j=0; j<(sz*sz); j++){
if(j%2==0)
*(ptrb+ j)=*(ptra + j) *10;
else
*(ptrb+j)=*(ptra+j);
if (j%4==0)
cout<<"\n";
cout<<setw(5)<<*(ptra+j);
}
cout<<endl;
cout<<endl;
c=12;
cout<<"**Diagonal Bottom Left"<<endl;
while (c>0){
cout<<*(ptra+ c)<<" "<<flush;
c=c-3;
}
return 0;
}
|