Created
June 29, 2021 16:53
-
-
Save Tamkien/3118bc17740dccea22e7bcab736cbf79 to your computer and use it in GitHub Desktop.
This file contains 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 main() | |
{ | |
int n,m,i,j; | |
float a[10][10]; | |
printf("Nhap so hang ma tran"); | |
scanf("%d", &m); | |
printf("Nhap so cot ma tran"); | |
scanf("%d", &n); | |
printf("\nNhap tung phan tu\n"); | |
for (i = 0; i < m; i++) { | |
for (j = 0; j < n; j++) { | |
printf("a[%d][%d]=", i, j); | |
scanf("%f", &a[i][j]); | |
} | |
} | |
// Neu co cai // thi la chu thich thoi, k chep nhe. | |
//Cau 2 | |
//chep nguyen 2 cai for cua de bai, sua printf va xoa scanf | |
for (i = 0; i < m; i++) { | |
for (j = 0; j < n; j++) { | |
//cai printf co them mot cai %f voi a[i][j] nua, chinh la gia tri cua tung phan tu. | |
//%f vi kieu du lieu cua phan tu la float | |
printf("a[%d][%d]= %f\n", i, j, a[i][j]); | |
} | |
} | |
//Cau 3 | |
//De yc in gtri cua hang cuoi cung, nen minh se for tu 0 den het so cot | |
float sum = 0; //cai sum nay de tinh tong, float la kieu du lieu | |
for (i = 0; i < n; i++) { | |
//m-1 la index cua hang cuoi cung. += de cong them vao cai sum. | |
sum += a[m-1][i]; | |
} | |
//in ra cai sum | |
printf("%f", sum); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment