for(i = 1; i < 5; i++)
{
printf("\n请输入密码:");
gets(password);
if (strcmp(password, "1") == 0)
{
while(1)
{
menu(); // 进入主界面
printf("请选择:");
do{
scanf("%d", &select);
}while (select < 1 || select > 7);
switch (select)
{
case 1: head = input(); break;
case 2: output(head); break;
case 3: search(head); break;
case 4: head = del(head); break;
case 5: head = modify(head); break;
case 6: head = order_sort(head); break;
case 7: quit(); break;
}
system("pause");
system("cls");
}
}
else
{
printf("密码错误\n请第%d次输入:", i + 1);//这句里边加个"\n",我觉得舒服一些。
gets(password); //这句没有必要吧,和上边的重复了。
}
}
************************************************StuInfo *input()
{
StuInfo *head = NULL, *p;
int i, flag = 1,a = 1 ;
float s = 0;
system("cls");
while (1)
{
printf("*****请输入第%d个学生的信息******\n",a);//我觉得加上这句输入的时候就更加清晰了!
p = (StuInfo *)malloc(LEN);
printf("\n请输入学生的序号:");
scanf("%d", &p -> order);
if (p -> order <= 0) break;
printf("\n请输入学生的学号:");
scanf("%s", p -> stu_id);
printf("\n请输入学生的姓名:");
scanf("%s", p -> name);
printf("\n请输入学生的性别:");
scanf("%s", p -> sex);
printf("\n请输入3门课的成绩:");
for (i = 1; i <= 3; i++)
{
switch (i)
{
case 1: printf("\n请输入数学成绩:"); break;
case 2: printf("\n请输入英语成绩:"); break;
case 3: printf("\n请输入c语言成绩:"); break;
}
scanf("%f", &p -> score[i - 1]);
while (p ->score[i - 1] < 0 || p -> score[i - 1] > 100)
{
printf("\n错误的输入,请重新输入:");
scanf("%f", &p -> score[i - 1]);
}
}
for (i = 1; i <= 3; i++)
s += p -> score[i];
p -> sum = s;
p -> ave = s / 3;
p -> next = head;
head = p;
}
a++;
return (head);
}
向你学习一下,我还没编出这么长的程序来了!
{
printf("\n请输入密码:");
gets(password);
if (strcmp(password, "1") == 0)
{
while(1)
{
menu(); // 进入主界面
printf("请选择:");
do{
scanf("%d", &select);
}while (select < 1 || select > 7);
switch (select)
{
case 1: head = input(); break;
case 2: output(head); break;
case 3: search(head); break;
case 4: head = del(head); break;
case 5: head = modify(head); break;
case 6: head = order_sort(head); break;
case 7: quit(); break;
}
system("pause");
system("cls");
}
}
else
{
printf("密码错误\n请第%d次输入:", i + 1);//这句里边加个"\n",我觉得舒服一些。
gets(password); //这句没有必要吧,和上边的重复了。
}
}
************************************************StuInfo *input()
{
StuInfo *head = NULL, *p;
int i, flag = 1,a = 1 ;
float s = 0;
system("cls");
while (1)
{
printf("*****请输入第%d个学生的信息******\n",a);//我觉得加上这句输入的时候就更加清晰了!
p = (StuInfo *)malloc(LEN);
printf("\n请输入学生的序号:");
scanf("%d", &p -> order);
if (p -> order <= 0) break;
printf("\n请输入学生的学号:");
scanf("%s", p -> stu_id);
printf("\n请输入学生的姓名:");
scanf("%s", p -> name);
printf("\n请输入学生的性别:");
scanf("%s", p -> sex);
printf("\n请输入3门课的成绩:");
for (i = 1; i <= 3; i++)
{
switch (i)
{
case 1: printf("\n请输入数学成绩:"); break;
case 2: printf("\n请输入英语成绩:"); break;
case 3: printf("\n请输入c语言成绩:"); break;
}
scanf("%f", &p -> score[i - 1]);
while (p ->score[i - 1] < 0 || p -> score[i - 1] > 100)
{
printf("\n错误的输入,请重新输入:");
scanf("%f", &p -> score[i - 1]);
}
}
for (i = 1; i <= 3; i++)
s += p -> score[i];
p -> sum = s;
p -> ave = s / 3;
p -> next = head;
head = p;
}
a++;
return (head);
}
向你学习一下,我还没编出这么长的程序来了!
最基础的往往是你最容易忽略的!