Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- void nhap(double **arr,int dong,int cot)
- {
- for(int i=0;i<dong;i++)
- {
- for(int j=0;j<cot;j++)
- {
- scanf("%lf",*(arr+i)+j);
- }
- }
- }
- void tong(double **arr1,double **arr2,int dong,int cot)
- {
- double **arr3=(double **)calloc(dong,sizeof(double*));
- for(int i=0;i<dong;i++)
- {
- *(arr3+i)=(double *)calloc(cot,sizeof(double));
- }
- for(int i=0;i<dong;i++)
- {
- for(int j=0;j<cot;j++)
- {
- arr3[i][j]=arr1[i][j]+arr2[i][j];
- }
- }
- for(int i=0;i<dong;i++)
- {
- for(int j=0;j<cot;j++)
- {
- printf("%.2lf ",arr3[i][j]);
- }
- printf("\n");
- }
- }
- int main()
- {
- int dong,cot;
- scanf("%d%d",&dong,&cot);
- double **arr1=(double **)calloc(dong,sizeof(double*));
- for(int i=0;i<dong;i++)
- {
- *(arr1+i)=(double *)calloc(cot,sizeof(double));
- }
- nhap(arr1,dong,cot);
- double **arr2=(double **)calloc(dong,sizeof(double*));
- for(int i=0;i<dong;i++)
- {
- *(arr2+i)=(double *)calloc(cot,sizeof(double));
- }
- nhap(arr2,dong,cot);
- tong(arr1,arr2,dong,cot);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement