帮忙看一下,怎么不能生成?调试不了?非常感谢
头文件student.h:# include <stdio.h>
# include <stdlib.h>
typedef struct student
{
char name[10];
int NO;
float English;
float math_score;
float Chinese;
float biology;
float physical;
float chemistry;
float total_score;
struct student * pNext;
}Student;
Student * pHead = (Student *)malloc(sizeof(Student));//建立头指针
int cnt = 0;//全局变量:输入的学生计数器
int derive_cnt;
Student * Add_Student(Student * pHead)//学生信息录入
{
Student * pTail = pHead;
Student * pNew;//头结点
pTail->pNext = NULL;
pNew = (Student *)malloc(sizeof(Student));
pTail->pNext = pNew;
printf("\n\n\n\n\n");
printf(" ");
printf("若学生学号输入为0,则信息录入结束!\n\n");
printf(" ");
printf("请输入学生学号(例如10320300):");
scanf_s("%d", &pNew->NO);
if (0 == pNew->NO)
{
system("cls");
printf("\n\n\n\n\n\n\n\n\n\n");
printf(" ");
printf("你没有输入学生信息!\n\n");
return pHead;
}
printf(" ");
printf("请输入学生姓名:");
scanf_s("%s", &pNew->name, 10);
printf(" ");
printf("请输入学生英语成绩:");
scanf_s("%f", &pNew->English);
printf(" ");
printf("请输入学生数学成绩:");
scanf_s("%f", &pNew->math_score);
printf(" ");
printf("请输入学生语文成绩:");
scanf_s("%f", &pNew->Chinese);
printf(" ");
printf("请输入学生生物成绩:");
scanf_s("%f", &pNew->biology);
printf(" ");
printf("请输入学生物理成绩:");
scanf_s("%f", &pNew->physical);
printf(" ");
printf("请输入学生化学成绩:");
scanf_s("%f", &pNew->chemistry);
pNew->total_score = pNew->English + pNew->math_score + pNew->Chinese +
pNew->Chinese + pNew->biology + pNew->physical +pNew->chemistry;//计算总分
pNew->pNext = NULL;//录入信息后,尾指针改变
pTail = pNew;
cnt++;//第一个学生的成绩
while (pTail->NO != 0)//录入条件
{
pNew = (Student *)malloc(sizeof(Student));
pTail->pNext = pNew;
pNew->pNext = NULL;
printf("\n");
printf(" ");
printf("请输入学生学号(例如10320300):");
scanf_s("%d", &pNew->NO);
if (pNew->NO != 0)
{
printf(" ");
printf("请输入学生姓名:");
scanf_s("%s", &pNew->name, 10);
printf(" ");
printf("请输入学生英语成绩:");
scanf_s("%f", &pNew->English);
printf(" ");
printf("请输入学生数学成绩:");
scanf_s("%f", &pNew->math_score);
printf(" ");
printf("请输入学生语文成绩:");
scanf_s("%f", &pNew->Chinese);
printf(" ");
printf("请输入学生生物成绩:");
scanf_s("%f", &pNew->biology);
printf(" ");
printf("请输入学生物理成绩:");
scanf_s("%f", &pNew->physical);
printf(" ");
printf("请输入学生化学成绩:");
scanf_s("%f", &pNew->chemistry);
pNew->total_score = pNew->English + pNew->math_score + pNew->Chinese +pNew->Chinese + pNew->biology + pNew->physical +pNew->chemistry;
pTail = pNew;
cnt++;
}
else
{
pTail->pNext = NULL;
free(pNew);
system("cls");
printf("\n\n\n\n\n\n\n\n");
printf(" ");
printf("学生信息输入完毕!\n\n");
printf(" ");
printf("你一共输入了%d个学生信息\n\n", cnt);
return pHead;
}
}
return pHead;
}
void Show_Student(Student * pHead)//查询学生成绩
{
if (cnt==0)
{
printf("\n\n\n\n\n");
printf(" ");
printf("请先录入学生成绩信息,再进行此操作!\n\n");
}
else
{
Student * p;
int t = 1;
p = pHead->pNext;
while (p != NULL)
{
printf(" 学生 NO:%d:\n\n", t);
printf(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n");
printf(" 该学生的姓名为: %s\n", p->name);
printf(" 该学生的学号为: %d\n", p->NO);
printf(" 该学生的语文成绩为: %0.1f\n", p->Chinese);
printf(" 该学生的数学成绩为: %0.1f\n", p->math_score);
printf(" 该学生的物理成绩为: %0.1f\n", p->physical);
printf(" 该学生的生物成绩为: %0.1f\n", p->biology);
printf(" 该学生的化学成绩为: %0.1f\n", p->chemistry);
printf(" 该学生的英语成绩为: %0.1f\n", p->English);
printf(" 该学生的总成绩为: %0.1f\n", p->total_score);
printf(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
printf("\n\n");
printf("\n");
t++;
p = p->pNext;
}
}
}
Student * Insert_Student(Student * pHead)//插入学生信息
{
int pos, t = 0;
if (cnt == 0)
{
printf("\a");
printf("\n\n\n\n\n\n\n\n\n\n");
printf("\n ");
printf("请先录入学生成绩信息,再进行此操作!\n\n");
return pHead;
}
printf("\n\n\n\n\n\n\n\n\n\n");
A:
printf("\n ");
printf("请输入你要插入的位置:");
scanf_s("%d", &pos);
if (pos < 1 || pos > cnt)
{
printf("\a");
printf("\n ");
printf("你输入的插入位置有误,请重新输入(位置必须介于1和%d之间)!\n", cnt);
goto A;
}
system("cls");
printf("\n\n\n\n\n\n\n\n\n\n");
Student * p = pHead;
Student * pInsert = (Student *)malloc(sizeof(Student));
printf(" ");
printf("请输入学生学号(例如10320300):");
scanf_s("%d", &pInsert->NO);
printf(" ");
printf("请输入学生姓名:");
scanf_s("%s", &pInsert->name, 10);
printf(" ");
printf("请输入学生英语成绩:");
scanf_s("%f", &pInsert->English);
printf(" ");
printf("请输入学生数学成绩:");
scanf_s("%f", &pInsert->math_score);
printf(" ");
printf("请输入学生语文成绩:");
scanf_s("%f", &pInsert->Chinese);
printf(" ");
printf("请输入学生生物成绩:");
scanf_s("%f", &pInsert->biology);
printf(" ");
printf("请输入学生物理成绩:");
scanf_s("%f", &pInsert->physical);
printf(" ");
printf("请输入学生化学成绩:");
scanf_s("%f", &pInsert->chemistry);
pInsert->total_score = pInsert->English +pInsert->math_score +pInsert->Chinese +pInsert->Chinese +pInsert->biology +pInsert->physical +pInsert->chemistry;
while (t < pos - 1)
{
p = p->pNext;
t++;
}//找到要插入的位置
pInsert->pNext = p->pNext;
p->pNext = pInsert;
printf("\n ");
printf("学生信息插入完毕!\n");
cnt++;
return pHead;
}
Student * Delete_Student(Student * pHead)
{
int pos, t = 0;
if (0 == cnt)
{
printf("\a");
system("cls");
printf("\n\n\n\n\n\n\n\n\n\n\n");
printf(" ");
printf("请先录入学生成绩信息,再进行此操作!\n\n");
return pHead;
}
printf("\n\n\n\n\n\n\n\n\n");
A:
printf("\n ");
printf("请输入你要删除信息的位置:");
scanf_s("%d", &pos);
if (pos<1 || pos>cnt)
{
printf("\a");
printf("\n ");
printf("你输入的位置有误,请重新输入(介于1和%d之间)\n", cnt);
goto A;
}
Student * p = pHead, *pT;
while (t < pos - 1)
{
p = p->pNext;
t++;
}//同上
pT = p->pNext;
p->pNext = p->pNext->pNext;
free(pT);//
cnt--;//删除的核心代码
printf("\n ");
printf("该学生信息删除成功!\n\n");
return pHead;
}
void Find_Student_NO(Student * pHead)//查询学生信息
{
if (cnt==0)
{
printf("\n\n\n\n ");
printf("请先进行录入操作后再进行查询!\n");
return;
}
Student * p = pHead;
int xuehao;
int t = 1;
printf("\n\n\n\n ");
printf("请输入要查找的学号(例如10320300):");
scanf_s("%d", &xuehao);
p = p->pNext;
while (p->NO != xuehao)
{
if (p->pNext==NULL)
{
printf("\a");
system("cls");
printf("\n\n\n\n\n\n\n\n\n\n\n");
printf(" ");
printf("无此学生信息!\n");
return;
}
p = p->pNext;
t++;
}
system("cls");
printf(" ");
printf(" ");
printf("你要查找的学生信息如下:\n\n");
printf(" 学生 NO:%d:\n\n", t);
printf(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n");
printf(" 该学生的姓名为: %s\n", p->name);
printf(" 该学生的学号为: %d\n", p->NO);
printf(" 该学生的语文成绩为: %0.1f\n", p->Chinese);
printf(" 该学生的数学成绩为: %0.1f\n", p->math_score);
printf(" 该学生的物理成绩为: %0.1f\n", p->physical);
printf(" 该学生的生物成绩为: %0.1f\n", p->biology);
printf(" 该学生的化学成绩为: %0.1f\n", p->chemistry);
printf(" 该学生的英语成绩为: %0.1f\n", p->English);
printf(" 该学生的总成绩为: %0.1f\n", p->total_score);
printf(" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
printf("\n\n");
printf("\n");
return;
}
头文件jinrucaozuo:
#include "student.h"
#include<conio.h>
void Jingru()
{
int i;
char password[4] = "123";
int pass = 0, cnt = 4;
while (cnt>0)
{
system("cls");
printf("\n\n\n\n\n\n\n\n\n");
printf(" ");
printf("请输入3位数密码:");
char a[4];
for (i = 0;;)
{
int c;
c = getchar();
if (c == 13)
break;
if (i < 3)
{
a[i] = c;
printf("%c", c);
printf("\b%c", '*');
a[i + 1] = '\0';
}
i++;
}
if (strcmp(a, password) == 0)
{
int in;
do
{
system("cls");
printf("\n\n\n\n");
printf(" *******");
printf("欢迎进入学生信息管理系统");
printf("*******\n");
printf(" | 1. 录 入 学 生 信 息 |\n");
printf(" | 2. 删 除 学 生 信 息 |\n");
printf(" | 3. 查 询 学 生 信 息 |\n");
printf(" | 4. 添 加 学 生 信 息 |\n");
printf(" | 5. 添 查 学 生 信 息 |\n");
printf(" | 6. 排 序 学 生 信 息 |\n");
printf(" | 0. 退 出 |\n");
printf(" **************************************\n");
printf("\n");
printf("请输入您要选择的选项:(0——6):\n");
scanf_s("%d", &in);
if (in <= 5 && in >= 0)
{
switch (in)
{
case 1:
system("cls");
Add_Student(pHead);
printf(" ");
system("pause");
break;
case 2:
system("cls");
Delete_Student(pHead);
printf(" ");
system("pause");
break;
case 3:
system("cls");
printf("\n\n\n\n\n\n");
Show_Student(pHead);
printf(" ");
system("pause");
break;
case 4:
system("cls");
Insert_Student(pHead);
printf(" ");
system("pause");
break;
case 5:
system("cls");
printf("\n\n\n\n\n\n");
Find_Student_NO(pHead);
printf("\n ");
system("pause");
break;
default:
system("cls");
printf("\n\n\n\n\n\n\n\n\n\n\n\n");
printf(" ");
printf("你选择了返回,程序即将返回主界面!\n\n");
printf(" ");
system("pause");
break;
}
}
else
{
printf("\n ");
printf("请输入0-9之间的数字!\n\n");
printf(" ");
system("pause");
}
} while (in != 0);
}
else
{
system("cls");
printf("\n\n\n\n\n\n\n\n\n");
printf(" ");
printf("密码输入错误!\n\n");
cnt--;
printf(" \n");
printf(" 你还有%d次机会!\n\n", cnt);
system("pause");
if (cnt == 0)
{
system("cls");
printf("\n\n\n\n\n\n\n\n\n");
printf(" \n");
printf(" 密码错误!\n\n");
}
}
}
}
源文件scm:
#include <stdio.h>
#include <stdlib.h>
#include<graphics.h>
#include"jinrucaozuo.h"
#include<windows.h>
int main(void)
{
printf("\n\n\n\n\n\n\n\n");
printf(" ");
printf("欢");
printf("迎");
printf("使");
printf("用");
printf("学");
printf("生");
printf("管");
printf("理");
printf("系");
printf("统\n");
int in;
do
{
system("cls");
printf("\n\n\n\n\n\n\n\n");
printf(" ");
printf("~~~~~~~~~~~~~~~~~~~~~\n\n");
printf(" ");
printf(" 您即将进入系统! \n");
printf(" \n ");
printf(" ");
printf("~~~~~~~~~~~~~~~~~~~~~\n");
printf(" ");
printf("是否进入系统?\n");
printf(" 进入选择1:\n");
printf(" ");
printf("退出选择2:");
scanf_s("%d", &in);
if (in == 1)
{
Jingru();
}
else
{
printf("\n ");
printf("请输入1或者2\n\n");
printf(" ");
system("pause");
}
} while (in != 1);
printf(" ");
return 0;
}