学生管理系统源代码

  • 格式:doc
  • 大小:42.00 KB
  • 文档页数:21

#include〈iostream>

#include〈stdlib.h〉

#include〈string.h〉

#include

#define INIT_SIZE 10

#define INCRE_SIZE 10

#define SUBJECT_NUM 3

#define LEN 3

void show_Start();

void show_Table();

void addRecord();

void Info_delete();

void deleteRecord();

void delete_Num(int);

void delete_Name(char tarName[]);

void Info_modify();

void modifyRecord();

void modify_Num(int);

void modify_Name(char[]);

void Info_query();

void queryRecord();

void query_Num(int);

void query_Name(char[]);

void display();

void quit();

void menu_CMD();

char *subject[SUBJECT_NUM] =

struct STUDENT {

int num;

char name[20];

char sex;

float score[SUBJECT_NUM];

};

//struct STUDENT stu[LEN + 1];

//STUDENT *record = (STUDENT*)malloc(sizeof(STUDENT)*INIT_SIZE);

int static stuNum = 0;

//

STUDENT *record = (STUDENT*)malloc(sizeof(STUDENT)*INIT_SIZE);;

int main()

//record = (STUDENT*)malloc(sizeof(STUDENT)*INIT_SIZE);

//STUDENT *record = (STUDENT*)malloc(sizeof(STUDENT)*INIT_SIZE);

/*

record[1]。num = 1001;

strcpy(record[1]。name,”Jason");

record[1]。sex = 'M’;

record[1].score[0] = 85。0;

record[1]。score[1] = 90。0;

record[1].score[2] = 95。0;

record[2]。num = 1002;

strcpy(record[2]。name,”Jerry”);

record[2]。sex = 'M’;

record[2]。score[0] = 85。0;

record[2].score[1] = 90.0;

record[2]。score[2] = 95.0;

record[3]。num = 1003; strcpy(record[3]。name,”Jessie”);

record[3]。sex = 'F’;

record[3]。score[0] = 85。0;

record[3]。score[1] = 90.0;

record[3]。score[2] = 95。0;

*/

/*

Info_modify();

int key;

cout〈

cin〉〉key;

if(key == 1)

{

int targetNum;

cout

cin〉>targetNum;

modify_Num(targetNum);

cout〈〈endl;

display();

}

if(key == 2)

char targetName[20];

cout<

cin>>targetName;

modify_Name(targetName);

cout〈

display();

}

if(key == 3) {

exit(0);

*/

show_Start();

menu_CMD();

return 0;

}

void show_Start()

{

//cout〈

cout<〈” **************************************** ”〈〈endl;

cout<<" "〈

cout〈<” "〈〈endl;

cout<<” ”<

cout〈〈” ”〈〈endl;

cout〈〈" Made by Jason ”〈

cout<〈” **************************************** ”〈〈endl;

//。

void show_Table()

cout〈<” 〈〈”\t"〈〈” ”<<"\t”<〈” cout<〈”\t"<〈subject[0]〈〈"\t"〈

cout<〈endl;

}

void menu_CMD()

{ int key;

while(1)

cout〈〈”1。 <〈endl;

cout〈〈”2。 <〈endl;

cout<〈”3. <

cout〈〈”4。 <

cout<〈"5. 〈〈endl;

cout〈<”6。 〈〈endl;

cout〈<”

cin〉〉key;

while(1)

if((key 〈 1)||(key 〉 6))

{

int key;

cout<< ”<〈endl;

cout〈< (1 — 5) : ”;

cin〉〉key;

else

{

break;

}

switch(key)

case 1:

addRecord();

break;

case 2:

deleteRecord();

break;

case 3:

modifyRecord();

break;

case 4:

queryRecord(); break;

case 5:

display();

break;

case 6:

quit();

break;

}

}

///////////////////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////////////////

//

void addRecord()

{

if(stuNum == 0)

cout〈〈 <

stuNum++;

else

cout<<” 〈〈endl;

stuNum++;

//

if(stuNum 〉 INIT_SIZE)

cout〈〈 ”<〈endl;

record = (STUDENT*)realloc(record,(INIT_SIZE + INCRE_SIZE)*sizeof(STUDENT));

cout<〈" !”〈〈endl;

cout〈〈” 〈〈endl;

cout<〈” (Y/N) : ”;

char choi;

cin>〉choi;

if((choi == ’Y’)||(choi == 'y'))

{

cout〈〈" : ";

cin〉〉record[stuNum]。num;

cout〈<” : ”;

cin〉〉record[stuNum].name;

cout〈<”(M , F) : ”;

cin〉〉record[stuNum]。sex;

int i;

for(i = 0;i 〈 SUBJECT_NUM;i++)

{

cout〈〈” ”<

cin〉〉record[stuNum]。score[i];

if((choi == ’N’)||(choi == ’n'))

cout〈<" 〈

cout〈〈endl;

}

cout〈〈 <

cout<〈endl;

}

//////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////

// \

//deleteRecord

void Info_delete()

{