Home > Back-end >  C how to define your own a key combination in the end of input?
C how to define your own a key combination in the end of input?

Time:10-06

Pray god help, int Information: setdown ()
{
int n;//input one-time to input the number of people,
Int b;//the temporary candidate number is assigned to variable b, is used to calculate candidate number is eight digits
Cout & lt; <"Please enter school students:" & lt; Cin & gt;> n;

If (_access (" D: \ \ information. TXT ", 0).=0)//to determine whether a file exists, if there is, just write the following
{
Ofstream outf (" D: \ \ information. TXT ", the ios: : app);//open the file, not the create
if (! Outf)//to determine whether a file open
{
Cout & lt; <"Always open the file \ n" & lt; return 0;
}
Outf & lt; <'\ t' & lt; <'\ t' & lt; <'\ t' & lt; <"The first result summary table" & lt; Outf & lt; <'\ t' & lt; <"Candidate number" & lt; <'\ t' & lt; <'\ t' & lt; <"Name" & lt; <'\ t' & lt; <"Chinese" & lt; <'\ t' & lt; <"Mathematics" & lt; <'\ t' & lt; <"English" & lt; <'\ t' & lt; <"Total" & lt; Outf & lt; <"(composed of eight digit)" & lt; <"(in Chinese)" & lt; Outf. Close ();//close the file
}

For (int I=0; I & lt; n; I++)
{
For (;; )//currently playing dead cycle, if the format error will not be able to perform the next step
{
int a=0;//each time to put this value to zero, a new computing candidate number digits
Cout & lt; <"Please enter the student candidate number (8 digits), name, Chinese, maths, English subjects:" & lt; Cin & gt;> Num & gt;> The name & gt;> Chinese & gt;> Math & gt;> english;
B=num.
While (b)//in addition to the 10 method to calculate and candidate number digits
{
+;
B=b/10;
}

If (a==8)//it is equal to 8 digits, is executed next
{
break;
}
The else
{
Cout & lt; <"The format is wrong, please input again! \ n "& lt; }
}

Sum=Chinese, math and English;//calculate the total score

Ofstream outf;//open the file, in the form of additional, each input information is saved a
Outf. Open (" D: \ \ information. TXT ", the ios: : app);
Outf & lt; <'\ t' & lt; Outf. Close ();//close the file

}
} in the add a show me

CodePudding user response:

O god, how BBS are dead, there is no answer?

CodePudding user response:

Enter the hair on their judgment in a negative value

CodePudding user response:

Cin. Getline (temp1, num 1, 0).
When the input is to press Enter and end of the input file (Ctrl + Z), then press Enter to stop input,
  • Related