#include "stdio.h"
#include <conio.h>
#include "c.h"
struct student
{
int sequence; //序号
char name[20];
int number;//学号
char sex;
int score[3];
}stu[1000];
void Averone() //Get the average score of one person
{
int a;
printf("Enter the student's number that you want to get the average:");
scanf("%d",&a);
for(int i=0;stu[i].number!=0;i++)
{
if(a==stu[i].number)
{
printf("The student's average score is %d",(stu[i].score[0]+stu[i].score[2]+stu[i].score[3])/3);
return;
}
}
printf("Wrong number!");
return;
}
void Averall() //Get the average of certain subject
{
int a,sum=0;
printf("Enter the subject that you want to get the average:");
scanf("%d",&a);
switch(a)
{
case 1:
{
for(int i=0;stu[i].number!=0;i++)
sum +=stu[i].score[0];
printf("The subject's average is %f",(float)sum/++i);
}break;
case 2:
{
for(int i=0;stu[i].number!=NULL;i++)
sum +=stu[i].score[1];
printf("The subject's average is %f",(float)sum/++i);
}break;
case 3:
{
for(int i=0;stu[i].number!=NULL;i++)
sum +=stu[i].score[2];
printf("The subject's average is %f",(float)sum/++i);
}break;
default:
printf("Dataerror!");
}
printf("press any key to continue.............");
getchar();
return;
}
void found() //Creat
{
int i=0;
printf("*************************** Welcome to use this system! ***********************************");
printf("Press any key to continue.....................................");
getchar();
printf("Enter the student's information at the following order(xuehao xingming xuhao 3ke fen shu ) and use a space to separate each of them:");
printf("Please enter the student's number(enter 0 to exit): ");
scanf("%d",stu[0].number);
do
{
scanf("%d %s %d %d %d %d %d",stu[0].name,stu[i].number,stu[i].sex,stu[i].score[i],stu[i].score[1],stu[i].score[2]);
stu[i].sequence=i+1;
printf("Enter the sex male/female(1/0) ");
scanf("%d",&stu[i].sex);
i++;
printf("Please enter the student's number(enter 0 to exit): ");
scanf("%d",stu[i].number);
}while(stu[i].number);
menu();
}
void menu() //the menu
{
int c;
printf("\t1. Enter the student's information\n\t2.Print the student's information\t\n3.Get the average score\t\n4.Get the highest score\t\n5.exit!");
printf("Enter you choice:");
scanf("%d",&c);
switch(c)
{
case 1:found();break; //Found one record
case 2:menuprint();break; //Print the srudent's information
case 3:menuaver();break; //Get the average score of the student
case 4:menuhigh();break; //Get the highest score of the student
case 5:out(); //Get out the progam
default:
printf("Dataerror!");
}
}
void menuprint() //Print the information
{
int c;
printf("\t1.Print all the students'information\t\n2.Print the information according to the sex\t\n3.Print a certain student's information\t\n4.Scores that all above 80\t\n5.Return");
scanf("%d",&c);
switch(c)
{
case 1:Printall();break; //Print all the students'information
case 2:Printsex();break; //Print the information according to the sex
case 3:Printnumber();break; //Print a certain student's information
case 4:Printscore();break; //Scores that all above 80
case 5:return; //Return
default:
printf("Dataerror!");
}
}
void menuaver()//Get the average score
{
int c;
printf("\t1.Get one subject's average score\t\n2.Get one student's average score\t\n3.Return");
scanf("%c",&c);
switch(c)
{
case 1:Averall();break; //Get one subject's average score
case 2:Averone();break; //Get one srudent's average score
case 3:return; //Return
default:
printf("Dataerror!");
}
}
void menuhigh() //Get the highest score
{
int c;
printf("\t1.Get the highest score of one subject\n\t2.Get the highest score of one's average score\t\n3.Return");
scanf("%d",&c);
switch(c)
{
case 1:searchone();break; //Get the highest score of one subject
case 2:search();break; //Get the highest score of one's average score
case 3:return; //Return
default:
printf("Dataerror!");
}
}
void out()
{
exit(1);
}
void Printall() //Print all the students' scores
{
printf("All the students' scores are:");
for(int i=0;i<1000&&stu[i].number!=0;i++)
printf("%d %d %d %d ",stu[i].sequence,stu[i].score[0],stu[i].score[1],stu[i].score[2]);
}
void Pirntsex() //Print the scores according to the sex
{
int c,i;
printf("Enter the sex male/female(1/0) ");
scanf("%d",&c);
switch(c)
{
case 1:
for(i=0;(i<1000)&&(stu[i].number!=0)&&(stu[i].sex==1);i++)
printf("%d %d %d %d ",stu[i].sequence,stu[i].score[0],stu[i].score[1],stu[i].score[2]);
case 0:
for(i=0;(i<1000)&&(stu[i].number!=0)&&(stu[i].sex==1);i++)
printf("%d %d %d %d ",stu[i].sequence,stu[i].score[0],stu[i].score[1],stu[i].score[2]);
default:
printf("Dataerror!");
}
}
void Printnumber() //Print the scores according to the student's number
{
int c,i;
printf("Enter the student's number:");
scanf("%d",&c);
for(i=0;(i<1000)&&(stu[i].number!=0);i++)
if(stu[i].number==c)
printf("%d %d %d %d ",stu[i].sequence,stu[i].score[0],stu[i].score[1],stu[i].score[2]);
}
void Printscore() //The students all the scores of whom are above 80
{
for(int i=0;(i<1000)&&(stu[i].number!=0);i++)
if((stu[i].score[0]>80)&&(stu[i].score[1]>80)&&(stu[i].score[2]>80))
printf("%d %d %d %d ",stu[i].sequence,stu[i].score[0],stu[i].score[1],stu[i].score[2]);
}
void search() //Get the student's information whose average score is highest of all
{
int i,n;
float max;
max=(float)(stu[0].score[0]+stu[0].score[1]+stu[0].score[2])/3;
for(i=0;i<1000&&stu[i].number!=0;i++)
if((float)(stu[0].score[0]+stu[0].score[1]+stu[0].score[2])/3>max)
n=i;
printf("%d %d %d %d %d",stu[n].sequence,stu[n].number,stu[n].score[0],stu[n].score[1],stu[n].score[2]);
if(stu[n].sex==1)
printf(" sex: male");
else printf(" sex: female");
}
void searchone() //Get the student's information whose certain subject's score is the highest
{
int i,c,max,n;
printf("Enter the subject(0/1/2):");
scanf("%d",&c);
max=stu[0].score[c];
for(i=0;i<1000&&stu[i].number!=0;i++)
if(stu[i].score[c]>max)
n=i;
printf("%d %d %d %d %d",stu[n].sequence,stu[n].number,stu[n].score[0],stu[n].score[1],stu[n].score[2]);
if(stu[n].sex==1)
printf(" sex: male");
else printf(" sex: female");
}
void main() // the main menu
{
menu();
out();
}
编译有错误 可是 怎么改呢?
----------------解决方案--------------------------------------------------------
路过
----------------解决方案--------------------------------------------------------
晕。这么长。错误大概在哪一样也说一下么!
----------------解决方案--------------------------------------------------------
错误的信息是这样的
--------------------Configuration: s - Win32 Debug--------------------
Compiling...
s.cpp
Linking...
s.obj : error LNK2001: unresolved external symbol "void __cdecl Printsex(void)" (?Printsex@@YAXXZ)
Debug/s.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
s.exe - 2 error(s), 0 warning(s)
这是在VC 下的编译结果
----------------解决方案--------------------------------------------------------