mn giúp tìm lổi code này với
#include<iostream>
#include<math.h>
#include <string.h>
#include <fstream>
using namespace std;
#define max 100
int n;
int a[100][100];
//ghi file ra o d
void ghifile(string s)
{
   ofstream matran (s,ios :: out) ;
    cin>>n;
     matran<<n<<endl;
     for(int i=0;i<n;i++)
		{
		for(int j=0;j<n;j++)
			{
				cin>>a[i][j]; 
				matran<<a[i][j]<<" "; 
} 
		matran<<"\n";
}
matran.close();
}
//doc file tu o dia
void docfile(string s)
{
ifstream ReadFile (s,ios :: in);
if(ReadFile.fail()){
cout << "Kiem tra lai file dau vao!";
system("pause");
}
ReadFile >> n;
for (int i = 0; i < n; i ++)
{
	for (int j = 0; j < n; j ++)
		{
			ReadFile >> a[i][j];
				cout << a[i][j] << " ";
		}
	cout << endl;
}
ReadFile.close();
}
// cau a
//kiem tra xem do thi co hop le hay khong
int dthople ( int a[100][100],int &n,string s)
{
    for(int i=0;i<n;i++)
	{	
      	   if(a[i][i]!=0)
		{
			return 0;
		}
	}
	return 1;
}
//cau b
//kiem tra do thi co huong hay vo huong
bool kt_dt(int a[100][100],int &n,string s)
{
    for(int i=0;i<n;i++)
       {
         if(a[i][i]!=0)
          {
			  return 0;
		 }
        
       }
      return 1;
}
int main()
{
 string s="E:\\dl.txt";
int n,a[100][100];
int chon=1;
while(chon!=0)
{
cout<<" ------MENU-------"<<endl;
cout<<"1. Kiem tra do thi co hop le hay khong"<<endl;
cout<<"2. kiem tra do thi co huong hay vo huong"<<endl;
cout<<"3.ghi do thi ra file "<<endl;
cout<<"4.doc do thi tu file"<<endl;
cout<<"0.Thoat"<<endl;
cin>>chon;
if(chon==1)
{
	if(dthople (a,n,s)!=0)
		cout<<"do thi hop le"<<endl;
	else
			cout<<"do thi ko hop le"<<endl;
	
}
	
if(chon==2)
{
    if(kt_dt(a,n,s)==0)
{
    cout<<" do thi co huong"<<endl;
}
else
{cout<<"do thi nay vo huong"<<endl;}
}
if(chon==3) 
{
ghifile(s);
cout<<" da ghi ra file thanh cong"<<endl;
}
if(chon==4) docfile(s);
}
} 
      
     83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?
    83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?