-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path0000.cpp
More file actions
38 lines (36 loc) · 811 Bytes
/
0000.cpp
File metadata and controls
38 lines (36 loc) · 811 Bytes
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<stdio.h>
#include<iostream>
using namespace std;
void swap(int *a,int *b){
*a=*a^*b;
*b=*a^*b;
*a=*a^*b;
}
void MatrixInplaceTranspose(int a[10][10],int r,int c){
for(int i=0;i<c;i++){
for(int j=0;j<i;j++)swap(&a[i][j],&a[j][i]);
}
}
int main(void)
{
int r = 2, c = 3;
int size = r*c;
int a[10][10];
for(int i=0;i<r;i++){
for(int j=0;j<c;j++)a[i][j]=i+j;
}
for(int i=0;i<r;i++){
for(int j=0;j<c;j++)cout<<a[i][j]<<" ";
cout<<endl;
}
MatrixInplaceTranspose(a, r, c);
swap(&r,&c);
cout<<endl<<endl;
for(int i=0;i<r;i++){
for(int j=0;j<c;j++)cout<<a[i][j]<<" ";
cout<<endl;
}
//delete[][] a;
system("pause");
return 0;
}