Advertisement
huskyIT

tong2MaTran

Mar 18th, 2017
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. void nhapmang(float x[][100], int row, int col)
  4. {
  5. int i,j;
  6. for(i=0; i<row; i++)
  7. {
  8. for(j=0; j<col; j++)
  9. {
  10. printf("nhap a[%d][%d]: ",i+1,j+1);
  11. scanf("%f",&x[i][j]);
  12. }
  13. }
  14. }
  15.  
  16. void xuatmang(float x[][100], int row, int col)
  17. {
  18. int i,j;
  19. for(i=0; i<row; i++)
  20. {
  21. for(j=0; j<col; j++)
  22. {
  23. printf("%6.1f",x[i][j]);
  24. }
  25. printf("\n");
  26. }
  27. }
  28.  
  29. void tong(float a[][100], float b[][100], float c[][100], int row, int col)
  30. {
  31. int i,j;
  32. for(i=0; i<row; i++)
  33. for(j=0; j<col; j++)
  34. c[i][j]=a[i][j] + b[i][j];
  35.  
  36. for(i=0; i<row; i++)
  37. {
  38. for(j=0; j<col; j++)
  39. {
  40. printf("%6.1f",c[i][j]);
  41. }
  42. printf("\n");
  43. }
  44. }
  45.  
  46. int main()
  47. {
  48. float a[100][100], b[100][100], c[100][100], d[100][100];
  49. int dongA,dongB,cotA,cotB,m,n,k;
  50. printf("NHAP MA TRAN A:\n");
  51. printf("Nhap so dong: "); scanf("%d",&dongA);
  52. printf("Nhap so cot: "); scanf("%d",&cotA);
  53. nhapmang(a,dongA,cotA);
  54.  
  55. printf("NHAP MA TRAN B:\n");
  56. printf("Nap so dong: "); scanf("%d",&dongB);
  57. printf("Nhap so cot: "); scanf("%d",&cotB);
  58. nhapmang(b,dongB,cotB);
  59.  
  60. printf("\nMA TRAN A:\n");
  61. xuatmang(a,dongA,cotA);
  62. printf("\nMA TRAN B:\n");
  63. xuatmang(b,dongB,cotB);
  64.  
  65. printf("\nMA TRAN C=A+B:\n");
  66. tong(a,b,c,dongA,cotA);
  67.  
  68. return 0;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement