Home > Back-end >  C for loop problem, cannot use
C for loop problem, cannot use

Time:04-30

Please help me have a look at the c + + code, the problem is the for loop can't use, can only lose a message, and then "press any key to continue", the switch statement below mention, can't even show it, write this in the inheritance, zero error, 0 waring, hope everybody can help me find problem

CodePudding user response:

<>> <

CodePudding user response:

reference 1st floor gouyanfen response:
& lt; <>> <

But symbols have no ah

CodePudding user response:

Don't post screenshots, post code,

CodePudding user response:

This is the main function
# define N 5
Void main ()
{int I, j, num, sel, age;
CStudent s [N], temp;
Char name [20], major [20].
Int s1, s2, s3;
Cout<& lt;" Please please input student information: name, age - student id - professional - grade 2 to grade 1 - grade 3 "& lt; for(i=0; i{cin> Name> Age> Num> Major> S1 & gt;> S2 & gt;> S3.
S [I] elegantly-named setName (name);
S [I] setnum (num);
S [I] sets1 (s1);
S [I] sets2 (s2);
S [I] sets3 (s3);
S [I] setmajor (major);
S [I] gettotal ();
}
Cout<& lt;" Please select sort way: "& lt; Cin> Sel.
The switch (sel)
{
Case 1:
for(i=0; i{the for (j=0; jIf (s [j]. Journal of getnum () & gt; S [j + 1] getnum ())
{
Temp=s [j], [j] s=s [j + 1), s [j + 1)=temp;
}
Cout<& lt;" The name "& lt; & lt;" "<& lt;" Student id "& lt; & lt;" "<& lt;" Results 1 "& lt; & lt;" "<& lt;" Grade 2 "& lt; & lt;" "<& lt;" Results 3 "& lt; & lt;" "<& lt;" Overall "& lt; for(i=0; iS [I]. The display ();
} break;
Case 2:
for(i=0; i{the for (j=0; jIf (s [j] gettotal () & gt; S [j + 1] gettotal ())
{
Temp=s [j], [j] s=s [j + 1), s [j + 1)=temp;
}
Cout<& lt;" The name "& lt; & lt;" "<& lt;" Student id "& lt; & lt;" "<& lt;" Results 1 "& lt; & lt;" "<& lt;" Grade 2 "& lt; & lt;" "<& lt;" Results 3 "& lt; & lt;" "<& lt;" Overall "& lt; for(i=0; iS [I]. The display ();
} break;

Default: cout<& lt;" Please choose again "& lt;
}
}

CodePudding user response:

The
quoted zhao teacher reply: 3/f
don't post screenshots, post code,

I put up my main function in the comments section, please have a look, thank you

CodePudding user response:

All the relevant code post,

Some take to reply box in the toolbar above to take the light blue & lt;> The icon and select C/C + + will automatically appear in the drop-down list
[code]=c | [/code]


[code]=c code to paste here [/code]

CodePudding user response:

Reference:
 void main () 
{
Int I, j, num, sel, age;
CStudent s [N], temp;
Char name [20], major [20].
Int s1, s2, s3;
Cout<& lt;" Please please input student information: name, age - student id - professional - grade 2 to grade 1 - grade 3 "& lt; for(i=0; i{
Cin> Name> Age> Num> Major> S1 & gt;> S2 & gt;> S3.
S [I] elegantly-named setName (name);
S [I] setage (age);
S [I] setnum (num);
S [I] sets1 (s1);
S [I] sets2 (s2);
S [I] sets3 (s3);
S [I] setmajor (major);
S [I] settotal ();
}

Do {
Cout<& lt;" Please select sort way: "& lt; Cin> Sel.
The switch (sel)
{
Case 1:
for(i=0; i{
for(j=0; jIf (s [j]. Journal of getnum () & gt; S [j + 1] getnum ())
{
Temp=s [j], [j] s=s [j + 1), s [j + 1)=temp;
}
}
Cout<& lt;" The name "& lt; & lt;" "<& lt;" Student id "& lt; & lt;" "<& lt;" Results 1 "& lt; & lt;" "<& lt;" Grade 2 "
<& lt;" "<& lt;" Results 3 "& lt; & lt;" "<& lt;" Overall "& lt; for(i=0; iS [I]. The display ();
break;
Case 2:
for(i=0; i{
for(j=0; jIf (s [j] gettotal () & gt; S [j + 1] gettotal ())
{
Temp=s [j], [j] s=s [j + 1), s [j + 1)=temp;
}
}
Cout<& lt;" The name "& lt; & lt;" "<& lt;" Student id "& lt; & lt;" "<& lt;" Results 1 "& lt; & lt;" "<& lt;" Grade 2 "
<& lt;" "<& lt;" Results 3 "& lt; & lt;" "<& lt;" Overall "& lt; for(i=0; iS [I]. The display ();
break;
default:break;//cout<& lt;" Please choose again "& lt; }
} while (sel!=0);//enter 0, sort out
system("pause");
}

CodePudding user response:

Define CStudent source code?

CodePudding user response:

All the code you wrote all the,
  • Related