SQL面试题.docx
- 文档编号:22795913
- 上传时间:2023-04-28
- 格式:DOCX
- 页数:17
- 大小:16.69KB
SQL面试题.docx
《SQL面试题.docx》由会员分享,可在线阅读,更多相关《SQL面试题.docx(17页珍藏版)》请在冰豆网上搜索。
SQL面试题
#include"stdio.h"
#include"stddef.h"
#include
#include"stdafx.h"
#include"string.h"
#include
#defineMAX10
typedefstructstudent/*定义结构体*/
{
charname[MAX];/*姓名*/
intnum[MAX];/*学号*/
charsex[MAX];/*性别*/
floatchinese;/*语文*/
floatmathematic;/*数学*/
floatenglish;/*英语*/
floatcomputer;/*计算机*/
structstudent*next;/*结构体指针*/
}stu;
stu*head;/*头指针*/
voidprint()/*显示或打印函数*/
{
system("cls");
printf("\t\t\tScoreManageSystem\n");/*成绩管理系统*/
printf("<1>EnterRecord\t");/*输入数据*/
printf("<2>Display\t");/*显示*/
printf("<3>Insert\t");/*插入数据*/
printf("<4>Quest\t");/*访问数据*/
printf("<5>Update\t");/*以前数据*/
printf("<6>Save\t");/*保留数据*/
printf("<7>Fresh\t");/*更新数据*/
printf("<8>ChineseAverage\t");/*语文平均成绩*/
printf("<9>MathAverage\t");/*数学平均成绩*/
printf("<10>EnglishAverage\t");/*英语平均成绩*/
printf("<11>ComputerAverage\t");/*计算机平均成绩*/
printf("<12>Quit\t\n");/*退出*/
}
voidcin(stu*p1)/*输入相关数据的函数*/
{
printf("Entername:
\n");
scanf("%s",&p1->name);
printf("Enternum:
\n");
scanf("%d",&p1->num);
printf("Entersex:
\n");
scanf("%s",&p1->sex);
printf("Enterscore:
\n");
printf("Enterchinese:
\n");
scanf("%d",&p1->chinese);
printf("Entermath:
\n");
scanf("%d",&p1->mathematic);
printf("EnterEnglish:
\n");
scanf("%d",&p1->english);
printf("EnterComputer:
\n");
scanf("%d",&p1->computer);
}
stu*cindata()/*其他数据是否继续输入的函数*/
{
stu*p1,*p2;
inti=1;
charch;
p1=(stu*)malloc(sizeof(stu));
head=p1;
while(i)
{
cin(p1);
printf("DoyouWanttoContinue?
yesorno");/*是否继续输入数据*/
ch=getchar();
ch=getchar();
if(ch=='n'||ch=='N')
{
i=0;
p1->next=NULL;
}
else
{
p2=p1;
p1=(stu*)malloc(sizeof(stu));
p2->next=p1;
}
}
return(p1->next);
}
stu*lookdata(stu*p1)/*查看数据的函数*/
{
while(p1!
=NULL)
{
printf("Num:
%d\t",p1->num);
printf("Name:
%s\t",p1->name);
printf("Sex:
%s\t",p1->sex);
printf("\n");
printf("Chinese:
%d\t",p1->chinese);
printf("Math:
%d\t",p1->mathematic);
printf("English:
%d\t",p1->english);
printf("Computer:
%d\t",p1->computer);
printf("\n");
p1=p1->next;
}
returnp1;
}
voidinsert()/*通过比较学号来插入数据的函数*/
{
stu*p1,*p3,*p2;
p1=head;
p3=(stu*)malloc(sizeof(stu));
p3->next=NULL;
if(head==NULL){head=p3;return;}
cin(p3);
while(p1!
=NULL&&(p1->num
{/*通过学号的比较来插入*/
p2=p1;p1=p1->next;
}
if(p2==head){p3->next=head;head=p3;return;}
p3->next=p1;
p2->next=p3;
}
voidfind(stu*p2)/*通过姓名查找查看数据的函数*/
{
charname[20];
intb=0;
printf("Enterthenameofthestudentyouwanttofind:
");/*通过姓名查看*/
scanf("%s",name);
while(p2!
=NULL)
{
if(strcmp(name,p2->name)==0)
{
printf("Thedatayouwanthasbefound\n");
printf("Name:
%s\t",p2->name);
printf("Num:
%d\t",p2->num);
printf("sex%s\t",p2->sex);
printf("\n");
printf("Chinese:
%d\t",p2->chinese);
printf("Math:
%d\t",p2->mathematic);
printf("English:
%d\t",p2->english);
printf("Computer:
%d\t",p2->computer);
printf("\n");
b=1;
}
elseif(b==0)
{
printf("sorrynotfinddata!
");
p2=p2->next;
}
if(b==1)
{
print();
printf("Findone\n");
}
else
{
print();
printf("Notfind\n");
}
}
}
voidcaverage()/*求各学生语文平均分、最高和最低分成绩的函数*/
{
stu*p1;
inti;
floatmax=0.0,min=200.0;
floatsum=0.0,aver=0;
p1=head;
if(p1==NULL)
printf("notdata!
");
else
{
for(i=0;p1!
=NULL;i++,p1=p1->next)
sum+=p1->chinese;
aver=sum/i;
p1=head;
for(i=0;p1!
=NULL;i++,p1=p1->next)
{
if(max
max=p1->chinese;
}
p1=head;
for(i=0;p1!
=NULL;i++,p1=p1->next)
if(min>p1->chinese)
min=p1->chinese;
}
printf("ChineseAverage:
%f",aver);
printf("ChineseMax:
%f",max);
printf("ChineseMin:
%f",min);
}
voidmaverage()/*求各学生数学平均分、最高和最低分成绩的函数*/
{
stu*p1;
inti;
floatmax=0.0,min=200.0;
floatsum=0.0,aver=0;
p1=head;
if(p1==NULL)
printf("notdata!
");
else
{
for(i=0;p1!
=NULL;i++,p1=p1->next)
sum+=p1->mathematic;
aver=sum/i;
p1=head;
for(i=0;p1!
=NULL;i++,p1=p1->next)
{
if(max
max=p1->mathematic;
}
p1=head;
for(i=0;p1!
=NULL;i++,p1=p1->next)
if(min>p1->mathematic)
min=p1->mathematic;
}
printf("MatheAverage:
%f",aver);
printf("MatheMax:
%f",max);
printf("MatheMin:
%f",min);
}
voideaverage()/*求各学生英语平均分、最高和最低分成绩的函数*/
{
stu*p1;
inti;
floatmax=0.0,min=200.0;
floatsum=0.0,aver=0;
p1=head;
if(p1==NULL)
printf("notdata!
");
else
{
for(i=0;p1!
=NULL;i++,p1=p1->next)
sum+=p1->english;
aver=sum/i;
p1=head;
for(i=0;p1!
=NULL;i++,p1=p1->next)
{
if(max
max=p1->english;
}
p1=head;
for(i=0;p1!
=NULL;i++,p1=p1->next)
if(min>p1->english)
min=p1->english;
}
printf("EnglishAverage:
%f",aver);
printf("EnglishMax:
%f",max);
printf("EnglishMin:
%f",min);
}
voidcomaverage()/*求各学生计算机平均分、最高和最低分成绩的函数*/
{
stu*p1;
inti;
floatmax=0.0,min=200.0;
floatsum=0.0,aver=0;
p1=head;
if(p1==NULL)
printf("notdata!
");
else
{
for(i=0;p1!
=NULL;i++,p1=p1->next)
sum+=p1->computer;
aver=sum/i;
p1=head;
for(i=0;p1!
=NULL;i++,p1=p1->next)
{
if(max
max=p1->computer;
}
p1=head;
for(i=0;p1!
=NULL;i++,p1=p1->next)
if(min>p1->computer)
min=p1->computer;
}
printf("ComputerAverage:
%f",aver);
printf("ComputerMax:
%f",max);
printf("ComputerMin:
%f",min);
}
voidupdate(stu*p2)/*通过姓名查找来更新数据*/
{
charname[10];/*p2为指向结构体structstudent的指针*/
intb=0;
printf("EnterTheName");/*输入姓名*/
scanf("%s",name);
while(p2!
=NULL)
{
if(strcmp(name,p2->name)==0)
{
printf("Findyoudata\n");
scanf("Name:
%s",p2->name);
scanf("Num:
%s",p2->num);
scanf("Sex:
%s",p2->sex);
scanf("Chinese:
%d",p2->chinese);
scanf("Math:
%d",p2->mathematic);
scanf("english:
%d",p2->english);
scanf("Computer:
%d",p2->computer);
printf("Success!
");
b=1;
}
elseif(b==0)
printf("SorrynotFinddata!
");
p2=p2->next;
}
if(b==0)
{
print();
printf("SorrynotFinddata!
");
}
else
{
print();
printf("Finish!
");
}
}
voidsave(stu*p2)/*保留数据函数*/
{
FILE*fp;
charfile[10];
printf("Enterfilename");/*输入文件名*/
scanf("%s",file);
fp=fopen(file,"w");
while(p2!
=NULL)
{
fprintf(fp,"%s",p2->name);
fprintf(fp,"%s",p2->num);
fprintf(fp,"%s",p2->sex);
fprintf(fp,"%d",p2->chinese);
fprintf(fp,"%d",p2->mathematic);
fprintf(fp,"%d",p2->english);
fprintf(fp,"%d",p2->computer);
p2=p2->next;
}
fclose(fp);
}
charpassword[7]="123456";/*定义初始密码*/
voidmain()/*主函数*/
{
intchoice;
stu*p2;
chars[8];
intflag=0,i;/*标志项*/
intn=3;
do
{
printf("Enterpassword:
\n");
scanf("%s",s);
if(!
strcmp(s,password))/*进行密码匹配验证*/
{
printf("PASS\n\n\n");
flag=1;
break;
}
else
{
printf("ErrorEnteragain:
\n");
n--;
}
}
while(n>0);
if(!
flag)
{
printf("youhaveEnter3times!
");/*输入密码超过了3次!
!
*/
exit(0);/*自动退出*/
}
/*密码验证成功后进入的界面*/
printf("~~~~~~~~~~\t\t\t~~~~~~~~~~~~\n");/*操作界面*/
printf("\t\tWelcomtotheMis\n");
printf("Author:
-----\tClass:
------\tNum:
------\n");/*作者,班级和号码*/
printf("Adress:
HG\n");/*地址*/
printf("%%%%%%%%%%%%%%%%%%%%%%%%%%%\n");
printf("\t\tEnterOP:
\n");
printf("\n\n\n\n");
printf("==============\t\t==============\n");
printf("==============\t\t==============\n");
printf("\t\tEntertheMISyesorno\n");/*问进入系统与否*/
scanf("%d",&choice);
if(choice=='n'||choice=='N')
exit
(1);
print();
while
(1)
{
{printf("Enterchoice:
");
scanf("%d",&i);
if(i<1||i>13)
{
printf("Enternumfrom1to13:
\n");/*再从1-13中进行选择*/
exit
(1);
}
switch(i)
{
case1:
p2=cindata();/*其他数据是否继续输入的函数*/
break;
case2:
p2=lookdata(head);/*查看数据的函数*/
break;
case3:
insert();/*通过比较学号来插入数据的函数*/
break;
case4:
find(head);/*通过姓名查找查看数据的函数*/
break;
case5:
update(head);/*通过姓名查找来更新数据*/
break;
case6:
save(head);/*保留数据函数*/
break;
case7:
print();/*显示或打印函数*/
break;
case8:
caverage();/*求各学生语文平均分、最高和最低分成绩的函数*/
break;
case9:
maverage();/*求各学生数学平均分、最高和最低分成绩的函数*/
break;
case10:
eaverage();/*求各学生英语平均分、最高和最低分成绩的函数*/
break;
case11:
comaverage();/*求各学生计算机平均分、最高和最低分成绩的函数*/
break;
case12:
;/*空操作*/
case13:
exit
(1);/*退出*/
break;
}
main();
scanf("%d",&i);
}
}
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- SQL 试题
![提示](https://static.bdocx.com/images/bang_tan.gif)