//
Enter the filename: donors. TXT
Grand Patrons:
None!
Patrons:
0
0
0
0
The Program ended with exit code: 0
//
The following is a code, can you tell me the great spirit of all stripes, what's the problem???????
# include & lt; iostream>
# include & lt; string>
# include & lt; Fstream>
# include & lt; vector>
# include & lt; Cstdlib>
using namespace std;
Struct donor {
String name;
Double money.
};
Int main () {
Int n;
Char filename [20].
Cout<" Enter the filename: ";
Cin. Getline (filename, 20);
Ifstream infile.
Infile. Open (filename);
if(! Infile. Is_open ())
{
Cout<" Could not open "& lt;
}
(infile> N). The get ();
Vector
for(int i=0; i
Getline (infile, ar [I] name);
(infile> Ar [I] money). The get ();
}
Cout<" Grand Patrons: "& lt;
for(int i=0; i
=10000){
Cout
}
If (m==0)
Cout<" None!"
Cout<" Patrons: "& lt;
{
Cout
}
If (m==0)
Cout<" None!"
return 0;
}
CodePudding user response:
First statement, this is my baidu, no debugging# include & lt; iostream>
# include & lt; Fstream>
# include & lt; string>
Int main ()
{
using namespace std;
Struct Juan
{
String name;
Double k;
};
Int num=0, I=0;
Ifstream ifs.
The ifs. Open (" 2. TXT ");
Ifs> Num.
Const int count=num;
Juan * member=new Juan (count);
While (num -)
{
The ifs. The get ();
Getline (ifs, member [I] name);
Ifs> Member [I]. K;
i++;
}
Cout<" Grand Patrons: "& lt;Num=0;
for(i=0; iIf (member [I] k> 10000)
{
Coutnum++;
}
If (num==0)
Cout<" None "& lt;Num=0;
Cout<" Patrons: "& lt;for(i=0; i If (member [I] k<10000)
{
num++;
Cout}
If (num==0)
Cout<" None "& lt;return 0;
}
CodePudding user response:
Not debugging, the front part whether can open the file, display your text? Why https://bbs.csdn.net/topics/396510443
Int n;
(infile & gt;> N). The get ();
VectorAr (n);
For (int I=0; i{
Getline (infile, ar [I] name);
(infile & gt;> Ar [I] money). The get ();
}
Cout & lt; <"Grand Patrons:" & lt;Int m=0;
For (int I=0; iIf (ar [I] money & gt;=... )
{
Cout & lt;+ + m;
}
If (m==0)
Cout & lt; <"None!"m=0;
Cout & lt; <"Patrons:" & lt;For (int I=0; i If (ar [I] money<. )
{
Cout & lt;+ + m;
}
If (m==0)
Cout & lt; <"None!"Infile. Close ();
CodePudding user response:
The pipe ends and ends here ah, is really a good chance,CodePudding user response: