theanhkkt
Thú CƯng :
Số bài viết : 143 Điểm : 1509261 Được cảm ơn : 24 Ngày sinh : 22/12/1990 Tham gia ngày : 16/03/2010 Tuổi : 33 Đến từ : Kon Tum
| Tiêu đề: bài tập thực hành tuần 1 16/4/2010, 11:08 | |
| - Code:
-
//ds by t.a
#include #include #include void docmt(int a[50][50], int n); void sobac(int a[50][50],int n); void socanh(int a[50][50], int n); void readfile() { FILE * f; int tam, n; int m[50][50]; char * duongdan; cout<<"\nnhap duong dan file: "; gets(duongdan); f=fopen(duongdan,"r"); if(f==NULL) cout<<"\n khong doc duoc file."; else { fscanf(f, "%d" , &n); printf("%d",n); cout<<"\n"; for(int i=0;i { for(int j=0;j { fscanf(f ,"%d",&tam); cout<<<" "; m[i][j]=tam; } cout<<"\n"; } } fclose(f); cout<<"\n"; cout<<"\nma tran la: "; cout<<"\n"; cout<<<"\n"; docmt(m, n); cout<<"\n"; cout<<"\n so bac cua do thi la:"; sobac(m, n); cout<<"\n\n"; socanh(m,n); }
void docmt(int a[50][50], int n) { for(int i=0;i { for(int j = 0;j { cout< cout<<" "; } cout<<"\n"; } getch(); }
void sobac(int a[50][50],int n) { int tong =0; for(int i=0;i { tong=0; for(int j=0;j { tong+=a[i][j]; } cout<<"\nso bac cua dinh la: "<<<" la "< } getch(); } void socanh(int a[50][50], int n) { int tong=0; for(int i=0;i { for(int j=0;j { tong+=a[i][j]; } } cout<<"\nso canh cua do thi la la: "<
} void main() { clrscr(); readfile(); getch(); }
File dth1: - Code:
-
13 2 1 0 1 0 0 0 0 0 0 0 1 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 0 0 0 0 0 0 1 1 0 1 0 0 0 0 0 1 0 0 1 1 0 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 |
|