Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- void nhapmang(float x[][100], int row, int col)
- {
- int i,j;
- for(i=0; i<row; i++)
- {
- for(j=0; j<col; j++)
- {
- printf("nhap a[%d][%d]: ",i+1,j+1);
- scanf("%f",&x[i][j]);
- }
- }
- }
- void xuatmang(float x[][100], int row, int col)
- {
- int i,j;
- for(i=0; i<row; i++)
- {
- for(j=0; j<col; j++)
- {
- printf("%6.1f",x[i][j]);
- }
- printf("\n");
- }
- }
- void tong(float a[][100], float b[][100], float c[][100], int row, int col)
- {
- int i,j;
- for(i=0; i<row; i++)
- for(j=0; j<col; j++)
- c[i][j]=a[i][j] + b[i][j];
- for(i=0; i<row; i++)
- {
- for(j=0; j<col; j++)
- {
- printf("%6.1f",c[i][j]);
- }
- printf("\n");
- }
- }
- int main()
- {
- float a[100][100], b[100][100], c[100][100], d[100][100];
- int dongA,dongB,cotA,cotB,m,n,k;
- printf("NHAP MA TRAN A:\n");
- printf("Nhap so dong: "); scanf("%d",&dongA);
- printf("Nhap so cot: "); scanf("%d",&cotA);
- nhapmang(a,dongA,cotA);
- printf("NHAP MA TRAN B:\n");
- printf("Nap so dong: "); scanf("%d",&dongB);
- printf("Nhap so cot: "); scanf("%d",&cotB);
- nhapmang(b,dongB,cotB);
- printf("\nMA TRAN A:\n");
- xuatmang(a,dongA,cotA);
- printf("\nMA TRAN B:\n");
- xuatmang(b,dongB,cotB);
- printf("\nMA TRAN C=A+B:\n");
- tong(a,b,c,dongA,cotA);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement