nazanin2014
یک شنبه 04 فروردین 1392, 10:27 صبح
با سلام.من میخوام برنامه ای بنویسم که ترانهادهtransposآرایه رو محاسبه کنه.الان اینی که نوشتم runمیشه اما منو به جواب نمیرسونه.
خروجی:
1638204
1638204
1638204
1638204
1638204
ورودی: 3 2 1
6 5 4
9 8 7
#include<iostream>
using namespace std;
const int size=3;
void read(int a[size][size])
{
cout<<"baraye gereftane deraye"<<size*size<<"adad vared konid"<<size<<"radif vared konid"<<endl;
for(int i=0;i<size;i++){
cout<< "radif"<<i<<":";
for(int j=0;j<size;j++)
cin>>a[i][j];
}}
void trans(int at[size][size],int a[size][size])
{
int i,j;
int save;
for(int i=0;i<size;i++){
for(int j=0;j<size;j++){
a[i][j]=save;
at[j][i]=a[i][j];
at[j][i]=save;
cout<<save;
cout<<endl;
}}
}
int main()
{
int a[3][3],at[3][3];
read(a);
trans(a,at);
trans(a,at);
return 0;
}
خروجی:
1638204
1638204
1638204
1638204
1638204
ورودی: 3 2 1
6 5 4
9 8 7
#include<iostream>
using namespace std;
const int size=3;
void read(int a[size][size])
{
cout<<"baraye gereftane deraye"<<size*size<<"adad vared konid"<<size<<"radif vared konid"<<endl;
for(int i=0;i<size;i++){
cout<< "radif"<<i<<":";
for(int j=0;j<size;j++)
cin>>a[i][j];
}}
void trans(int at[size][size],int a[size][size])
{
int i,j;
int save;
for(int i=0;i<size;i++){
for(int j=0;j<size;j++){
a[i][j]=save;
at[j][i]=a[i][j];
at[j][i]=save;
cout<<save;
cout<<endl;
}}
}
int main()
{
int a[3][3],at[3][3];
read(a);
trans(a,at);
trans(a,at);
return 0;
}