Home > Back-end >  C a run said program to stop working
C a run said program to stop working

Time:10-12

C + + can compile and run can pass but it is a great god appear this kind of problem? Source program is as follows:
#include
#include
#include
#include
#include
#include
The class student
{private:
, school char name [20] [30], grade [10], profession [10], sex [20].//name. School, grade, professional
Double cpro, English, math, sun, aver.//subject
Int the order, the age, number;//rank, age, student id
Public:
Student () {}
Student
(char n [20], char SCH [30], char gra [10], char se [20], int ag,
Char pro [10], int nu, double cc, double eng, double ma, double su, double av)
{strcpy (name, n);
Strcpy (school, SCH);
Strcpy (grade, gra); Strcpy (profession, pro);
Cpro=cc; English=eng; Math=ma; Strcpy (sex, se); Age=ag; Number=nu; Sun=su; Aver=av;
}
Friend void main ();
};

Void main ()
{
cout<" Welcome to make B * * * * * * student achievement management system!"
cout<" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * "& lt; cout<" * * * * * * * * "student achievement management system & lt; cout<" * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * "& lt; cout<" * * * * * * * * * * * * * * * * * * * * * * * * * * "& lt; cout<" * * * * 0, input data "& lt; cout<" * * * * 1, increase data "& lt; cout<" * * 2, modify the data * * "& lt; cout<" * * "* * 3, according to the name query & lt; cout<" * * "* * 4, according to the student number query & lt; cout<" * * 5, output all the grades of the students * * "& lt; cout<" * * 6, failed to pass the query number * * "& lt; cout<" * * * * 7, exit system "& lt; cout<" * * * * * * * * * * * * * * * * * * * * * * * * * * "& lt; cout<" 0 to 7 digital manipulation "& lt; cout<"=====producer: tease than four groups of========="& lt; Char p; Char w;
Student * s [50];//pointer object, most save 50 students data
Ofstream * file [50];//is responsible for file insert
int i=0;
Int j=0;
Int flag=0;
Do//flag to judge whether the input effective
{
Cin> p;
If ((p>='0' & amp; & p<))
='7'flag=1;
The else
cout<" Command error! Please input again: "& lt; } while (flag==0);
Do {
Switch (p)//receiving options
{
Case '0' ://input data
{
char c;

, school char name [20] [30], grade [10], profession [10], sex [20].//name. School, grade, professional
Double cpro, English, math, sun, aver.//subject
Int the age, number;//rank, age, student id

Do {
cout<" Please input your name: ";
Cin> The name;
cout<" Please enter the student id: ";
Cin> Number;
cout<" Please enter the gender: ";
Cin> Sex;
cout<" Please enter the age: ";
Cin> The age;
cout<" Please enter the college: ";
Cin> school;
cout<" Please enter the grade: ";
Cin> grade;
cout<" Please enter the profession: ";
Cin> Profession;
cout<" Please enter the c + + grade: ";
Cin> Cpro.
cout<" Please input in English: ";
Cin> English;
cout<" Please enter the mathematics performance: ";
Cin> Math;
Sun=cpro + English + math;
Aver=sun/3;
coutThe file [j]=new ofstream (" D: \ \ documents ", the ios: : ate);
* the file [j] <" The name "& lt; "<" English & lt;" j++;
[I] s=new student (name, school, grade, sex, age, profession, number, cpro, English, math, sun, aver);
i++;
cout<" Data input is successful, want to continue to input (y/n) : ";
Cin> c;
coutDo
{
if(c! & amp;='y' & c!='n')
{
cout<" Command error! Please input again - -!" Cin> c;
}
The else
flag=1;
} while (flag==0);
} while (c=='y');
break;
}

Case '1' ://increase data
{
, school char name [20] [30], grade [10], profession [10], sex [20].
Int number, age;
Double cpro, English, math, sun, aver.

char c;
Do
{
cout<" ^. ^ to increase the student's name: please enter your ";
Cin> The name;
cout<" Please enter the student id: ";
Cin> Number;
cout<" Please enter the gender: ";
Cin> Sex;
cout<" Please enter the age: ";
Cin> The age;
cout<" Please enter the college: ";
Cin> school;
cout<" Please enter the grade: ";
Cin> grade;
cout<" Please enter the profession: ";
Cin> Profession;
cout<" Please enter the c + + grade: ";
Cin> Cpro.
cout<" Please input in English: ";
Cin> English;
cout<" Please enter the mathematics performance: ";
Cin> Math;
Sun=cpro + English + math;
Aver=sun/3;
coutThe file [j]=new ofstream (" d: \ \ documents ", the ios: : ate);
* the file [j] <" The name "& lt; "<" English & lt;"
  • Related