📄 zong wu项.c
字号:
wenttoxy(5,20);
printf("the record can't find!");
}
}
wenttoxy(5,20);
printf(" ");
wenttoxy(5,20);
printf("Will you want to continue to increase inquiry?(Y\y,N\n)");
do
{
c =getche();
if(c!='y' && c!='Y' && c!='n' && c!='N' )
{
wenttoxy(5,18);printf(" ");
printf("That you import is illegal character!");
}
else
if(c=='n'|| c=='N')
Search_Stu_Info();
else
{if(c=='y'|| c=='Y')
break;
}
}
while(1);
system("cls");
wenttoxy(10,5);printf("Search By Sno");
if(k!=0)
PrintInfo( str, k, 1,0,-1) ;
else
{
printf("system don't find record!");
getch();Main_Menu();
}
}
while(1);
}
/***********************************************************************************************
按姓名查找
(模糊查找)
**********************************************************************************************/
void SearchByName()
{ struct student temp[100];
char name[24];int k,i;k=0;
SearchNameVerification(name);
for(i=0;i<=counts;i++)
{
if(strstr(strupr(stu[i].name),strupr(name))!=0)
{
temp[k++]=stu[i];
break;
}
}
if(k!=0)
PrintInfo(temp, k, 1,0,-1);
else
{
printf("the record don't find,please any key to try again!");
getch();
Search_Stu_Info();
}
}
/*********************************************************************************************
查询学生信息的菜单界面
***********************************************************************************************/
void Search_Stu_Info()
{ char c;
system("cls");
wenttoxy(28,0);printf("****************************\n");
wenttoxy(28,1);printf("* Search Stu Info *\n");
wenttoxy(28,2);printf("****************************\n");
if(counts==0)
{
printf("it is not having records");
Main_Menu();
}
wenttoxy(28,3);printf("1-------Search By Sno \n");
wenttoxy(28,4);printf("2-------Search By Name\n");
wenttoxy(28,5);printf("0.back to Main Menu\n");
wenttoxy(5,18);printf("Please enter your choose[0-2]:\n") ;
while(1)
{
wenttoxy(36,18);c=getche();
if(!(c>='0' && c<='2'))
{
printf("your puts is wrong");
}
else
break;
}
switch(c)
{
case '1': wenttoxy(28,10);printf("the sno:");SearchBySno();break;
case '2':wenttoxy(28,10);printf("the name:");SearchByName(); break;
case '0':Main_Menu(); break;
}
}
/**********************************************************************************************
打印当前页面
参数:page表示传入的页面
flag
t
***********************************************************************************************/
int Printthis(int page,int counts,int flag,int t)
{
char select;
int totpage;
totpage=counts%10==0?counts/10:counts/10+1;
if(counts==0)
{
wenttoxy(5,18);
printf("it is not having record");getch();
Main_Menu();
}
do
{
wenttoxy(0,3);
printf("................................................................................\n");
wenttoxy(0,4);
printf("%-4s%-21s%-4s%-8s%-8s%-6s%-8s%-10s%-6s%5s","sno","name","age","chinese","english","math","physics","chemistry","total","avg");
wenttoxy(0,5);
printf("................................................................................\n");
wenttoxy(5,18);
printf("[%d/%d] [1]last page [2]next page [3]first page [4] end page [5]what page [6]delete [0]back\n",page,totpage);
wenttoxy(10,20);
printf("please select [0-6]:");
select=getche();
if((t==1 && !(select>='0' && select<='6')) || (t==0 && !(select>='0' && select<='5')))
{ if(select=='\r')
{
wenttoxy(5,21);printf("%*s",80," ");
wenttoxy(5,21);
printf("The content that you import is that empty space content imports [0-6] please again,");
}
else
{
wenttoxy(5,21);printf("%*s",100," ");
wenttoxy(5,21);printf("The number that you import has exceeded range, import again please[0-6]");
}
}
else
{ if(select=='0') Main_Menu();
else
break;
}
}
while(1);
return select;
}
/************************************************************************************************
打印学生信息
并能实现翻页功能
**********************************************************************************************/
void PrintInfo(struct student s[],int counts,int page,int flag,int t)
{
char select;char a;
float avg;double tot;int i;int totpage;int j;
j=0;
avg=0;
while(1)
{
totpage=counts%10==0?counts/10:counts/10+1;
for(i=(page-1)*10;i<page*10;i++)
{ tot=0;
for(j=0;j<=4;j++)
{
tot+=s[i].score[j];
}
avg=(float)tot/5;
wenttoxy(0,8+i-(page-1)*10);
if(i>=counts)
{
printf("%*s",800," ");
break;
}
else if(flag==0)
{
printf("%-4s%-20s%4d%8.1f%6.1f%8.1f%10.1f%8.1f%6.1f%6.1f",s[i].sno,s[i].name,s[i].age,
s[i].score[0],s[i].score[1],s[i].score[2],s[i].score[3],s[i].score[4],tot,avg);
}
else if(flag==1)
{
printf("%-4s%-20s%4d%8.1f%6.1f%8.1f%10.1f%8.1f%6.1f%6.1f", s[i].sno,s[i].name,s[i].age,
s[i].score[0],s[i].score[1],s[i].score[2],s[i].score[3],s[i].score[4]);
}
else if(flag==2)
{
printf("%-4s%-20s%4d%8.1f%6.1f%8.1f%10.1f%8.1f%6.1f%6.1f", s[i].sno,s[i].name,s[i].age,
s[i].score[0],s[i].score[1],s[i].score[2],s[i].score[3],s[i].score[4]);
}
}
select=Printthis( page, counts, 0,t);
switch(select)
{
case '1':if(page>1)
page--;break;
case '2':if(page<totpage)
page++;
break;
case '3':page=1;break;
case '4': page=totpage;break;
case '5': {
wenttoxy(30,19);
printf("please enter a chararcat:");
while(1)
{ page=getche();
page=page-48;
if(!(1<=page && page <=totpage))
{
wenttoxy(3,21);
printf("The figure that you import is illegal!");
wenttoxy(55,19);
}
else
{ wenttoxy(3,21);
printf(" ");
break;
}
}
break;
}
}
if( select=='6')
{
printf("dou you want to delete the record[y\\Y],other key back");
a=getche();
if(a=='Y'||a=='y') del(s);
else Search_Stu_Info();
}
}
}
/********************************************************************************************
按学号排序
k等于1表示降序排列
k等于-1时表升序
************************************************************************************************/
void OrderBySno(int k)
{
int i;char c;
struct student temp;
int flag;
if(k==1)
{
do
{
flag=1;
for(i=0;i<=counts-1;i++)
if(strcmp(stu[i+1].sno,stu[i].sno)>0)
{
temp=stu[i];stu[i]=stu[i+1];stu[i+1]=temp;
flag=0;
}
}while(! flag);
system("cls");
printf("sort is successd,will you want to sort of information?[y/Y]");
while(1)
{
c=getche();
if(c=='y'||c=='Y')
{
PrintInfo( stu, counts, page,0,-1);
break;
}
else
Sort_Stu_Info();
}
}
else
{
if(k==-1)
do
{
flag=1;
for(i=0;i<=counts-1;i++)
if(strcmp(stu[i+1].sno,stu[i].sno)<0)
{
temp=stu[i];stu[i]=stu[i+1];stu[i+1]=temp;
flag=0;
}
}
while(!flag);
}
system("cls");
wenttoxy(5,3);
printf("sort is successd,will you want to printf the sort of information?[y\Y]");
while(1)
{
c=getche();
if(c=='y'||c=='Y')
{
PrintInfo( stu, counts, page,0,-1);
break;
}
else
Sort_Stu_Info();
}
}
/***********************************************************************************************
按总分排序
************************************************************************************************/
void OrderByTotscore(int k)
{
struct student temp;char c;
double totscore[50]={0};
int i,j,min;
for(i=0;i<=counts-1;i++)
{
stu[i].totscore=stu[i].score[0]+stu[i].score[1]+stu[i].score[2]+stu[i].score[3]+stu[i].score[4];
}
if(k==-1)
{
for(i=0;i<counts;i++)
{ min=i;
for(j=i+1;j<counts;j++)
{ if(stu[min].totscore>stu[j].totscore)
{ min=j;
}
}
if(min!=i)
{ temp=stu[min];
stu[min]=stu[i];
stu[i]=temp;
}
}
printf("sort is successd,will you want to printf the sort of information?[y\Y]");
while(1)
{
c=getche();
if(c=='y'||c=='Y')
{
system("cls");
PrintInfo( stu, counts, page,0,-1);
break;
}
else
Sort_Stu_Info();
}
}
else
{
if(k==1)
{
for(i = 0;i <counts-1;i++)
for(j = i+1;j <=counts-1;j++)
{ if(stu[i].totscore <stu[j].totscore)
{ temp = stu[j];
stu[j] = stu[i];
stu[i] = temp;
}
}
}
printf("sort is successd,will you want to printf the sort of information?[y\Y]");
while(1)
{
c=getche();
if(c=='y'||c=='Y')
{
system("cls");
PrintInfo( stu, counts, page,0,-1);
break;
}
else
Sort_Stu_Info();
}
}
}
/*********************************************************************************************
统计平均分
*********************************************************************************************/
void tongjiavg()
{
int i;double avg,tot;tot=0;
if(counts!=0)
{
for(i=0;i<=counts-1;i++)
{
tot+=stu[i].score[0];
}
avg=tot/5.0;
wenttoxy(20,3);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -