Created
May 12, 2015 10:06
-
-
Save yask123/c85e694f1016234ff0f1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # include <stdio.h> | |
| int add(int a[][10],int b[][10],int n,int m,int r[10][10]) | |
| { | |
| int i,j; | |
| for(i=0;i<n;i++) | |
| { | |
| for(j=0;j<m;j++) | |
| { | |
| r[i][j]= a[i][j] + b[i][j]; | |
| } | |
| } | |
| return 0; | |
| } | |
| void fill(int b[][10],int n,int m) | |
| { | |
| int i,j; | |
| for(i=0;i<n;i++) | |
| { | |
| for(j=0;j<m;j++) | |
| { | |
| scanf("%d",&b[i][j]); | |
| } | |
| } | |
| } | |
| void transpose(int a[][10],int n,int m,int r[10][10]) | |
| { | |
| int i,j; | |
| for(i=0;i<n;i++) | |
| { | |
| for(j=i+1;j<m;j++) | |
| { | |
| int t; | |
| t = a[i][j]; | |
| a[i][j]=a[j][i]; | |
| a[j][i]=t; | |
| } | |
| } | |
| } | |
| void print(int r[][10],int n,int m) | |
| { | |
| int i,j; | |
| for(i=0;i<n;i++) | |
| { | |
| for(j=0;j<m;j++) | |
| { | |
| printf("%d ",r[i][j]); | |
| } | |
| printf("\n"); | |
| } | |
| } | |
| int main() | |
| { | |
| int a[10][10]; | |
| int b[10][10]; | |
| int n,m; | |
| int r[10][10]; | |
| scanf("%d %d",&n,&m); | |
| fill(a,n,m); | |
| fill(b,n,m); | |
| add(a,b,n,m,r); | |
| print(r,n,m); | |
| int t[10][10]; | |
| transpose(r,n, m,t); | |
| print(r,n,m); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment