c++ c++ c++ c++

来源:百度知道 编辑:UC知道 时间:2024/06/21 18:41:46
#include <fstream>
#include <string>

class Read
{
private :

int left,right,row;

public :

void Judgement(string S)

{

ifstream infile(S,ios::in|iso::nocreate);

if(!infile)

{
cout<<"open error!\n";
exit(1);
}

char c;

while(c=infile.get()!=EOF)
{
row++;

while(c!='\n')
{
if(c=='(')left++;
else if(c==')')right++;

}

if(left>=right)cout<<"Row "<<row<<" is true";
else cout<<"Row "<<row<<" is false";

}
cout<<"Confermation Complete.";

infile.close

using namespace std;

ios非iso

#include <fstream.h>
#include <string>

class Read
{
private :

int left,right,row;

public :
void Judgement()
{
ifstream infile("D:\a.log", ios::in | ios::nocreate);

if(!infile)

{
cout<<"open error!\n";
exit(1);
}

char c;

while(c=infile.get()!=EOF)
{
row++;

while(c!='\n')
{
if(c=='(')left++;
else if(c==')')right++;

}

if(left>=right)cout<<"Row "<<row<<" is true";
else cout<<"Row "<<row<<" is false";

}
cout<<"Confermation Complete.";

infile.close();
}

};

R