Advertisement
bestTamken

day so

Jun 15th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <conio.h>
  4. void NhapMang(int a[50][50], int hang, int cot)
  5. {
  6. for(int i=1; i<=hang; i++)
  7. {
  8. for(int j=1; j<=cot; j++)
  9. {
  10. printf("\nNhap A[%d][%d]: ",i,j);
  11. scanf("%d",&a[i][j]);
  12. }
  13. }
  14. }
  15. void InMang(int a[50][50], int hang, int cot)
  16. {
  17. for(int i=1; i<=hang; i++)
  18. {
  19. for(int j=1; j<=cot; j++)
  20. {
  21. printf("\nNhap A[%d][%d]=%d ",i,j,a[i][j]);
  22. }
  23. }
  24. }
  25. int TongTrenHangChan(int a[50][50], int hang, int cot)
  26. {
  27. int s=0;
  28. for(int i=1; i<=hang; i++)
  29. {
  30. if(i%2==0)
  31. for(int j=1; j<=cot; j++)
  32. s=s+a[i][j];
  33. else continue;
  34. }
  35. return s;
  36. }
  37. void LonNhatTrenTungHang(int a[50][50], int hang, int cot)
  38. {
  39. int min[50];
  40. for(int j=1; j<=cot; j++)
  41. {
  42. min[j]=a[1][j];
  43. for(int i=2; i<=hang; i++)
  44. {
  45. if(min[j]<a[i][j])
  46. min[j]=a[i][j];
  47. }
  48. printf("\nSo lon nhat tren hang %d la: %d",j,min[j]);
  49. }
  50. }
  51. void NhoNhatTrenTungCot(int a[50][50], int hang, int cot)
  52. {
  53. int max[50];
  54. for(int i=1; i<=hang; i++)
  55. {
  56. max[i]=a[i][1];
  57. for(int j=2; j<=cot; j++)
  58. {
  59. if(max[i]>a[i][j])
  60. max[i]=a[i][j];
  61. }
  62. printf("\nSo nho nhat tren cot %d la: %d",i,max[i]);
  63. }
  64. }
  65. main()
  66. {
  67. int a[50][50], hang, cot;
  68. printf("Nhap so hang va cot: ");
  69. scanf("%d%d",&hang,&cot);
  70. NhapMang(a,hang,cot);
  71. InMang(a,hang,cot);
  72. printf("Tong tren hang chan la %d", TongTrenHangChan(a,hang,cot));
  73. LonNhatTrenTungHang(a,hang,cot);
  74. NhoNhatTrenTungCot(a,hang,cot);
  75. printf("\n\n\a\a");
  76. getch();
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement