📄 图形式下拉菜单.txt
字号:
setfillstyle(SOLID_FILL,GREEN);
bar(170,210,470,270);
setcolor(RED);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,1);
settextjustify(CENTER_TEXT,CENTER_TEXT);
outtextxy(320,240,"continue? Y / else quit");
flagsure=getch();
if(flagsure=='y'||flagsure=='Y') flagcontinue=1;
else flagcontinue=0;
stu_data[j]=temp;j++;
clearblue();
}
free(pinfo);
setcolor(WHITE);
setfillstyle(SOLID_FILL,GREEN);
fillellipse(320,240,150,100);
setcolor(RED);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,2);
settextjustify(CENTER_TEXT,CENTER_TEXT);
outtextxy(320,240,"SAVE? Y/else");
flagsave=getch();
if(flagsave=='Y'||flagsave=='y')
savedata(stu_data); /* load function */
clearblue();
}
/******************************************************/
/*modify_mark fuction */ /* here use stu_mark[10] */
void modify_mark(void)
{ char *markitem[]={"Num","Name","English","Math","Phyics","Computer","C language"};
char flagsave,flagsure,tt[40];
int i,flagcontinue,j=0,k;
unsigned size;
void *pinfo=NULL;
struct mark temp,stu_mark[10];
mark(stu_mark);
clearblue();
setcolor(RED);
setfillstyle(SOLID_FILL,LIGHTGRAY);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,1);
settextjustify(RIGHT_TEXT,CENTER_TEXT);
bar(210,180,430,450);
for(i=0;i<7;i++)
{ outtextxy(320,190+i*30+15,markitem[i]) ;
setfillstyle(SOLID_FILL,BLACK);
bar(323,177+i*30+15,420,180+i*30+37);
}
size=imagesize(210,180,430,450);
pinfo=malloc(size);
getimage(210,180,430,450,pinfo);
flagcontinue=1;
while(flagcontinue==1)
{ putimage(210,180,pinfo,COPY_PUT);
settextjustify(CENTER_TEXT,CENTER_TEXT);
setcolor(YELLOW);
outtextxy(290,150,"Please input the court Mark");
setcolor(RED);
{ gotoxy(42,13);
gets(tt);temp.num=atol(tt);
gotoxy(42,13+1*2);
gets(temp.name);
for(k=0;k<5;k++)
{gotoxy(42,13+(k+2)*2);
gets(tt);temp.court[k]=atof(tt);
}
}
clearblue();
setfillstyle(SOLID_FILL,GREEN);
bar(170,200,560,280);
setcolor(RED);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,1);
settextjustify(CENTER_TEXT,CENTER_TEXT);
outtextxy(320,240,"continue? Y / else quit");
flagsure=getch();
if(flagsure=='y'||flagsure=='Y') flagcontinue=1;
else flagcontinue=0;
stu_mark[j]=temp;j++;
clearblue();
}
free(pinfo);
setcolor(WHITE);
setfillstyle(SOLID_FILL,GREEN);
fillellipse(320,240,150,100);
setcolor(RED);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,2);
settextjustify(CENTER_TEXT,CENTER_TEXT);
outtextxy(320,240,"SAVE? Y/else");
flagsave=getch();
if(flagsave=='Y'||flagsave=='y')
savemark(stu_mark);
clearblue();
}
/****************************************************/
/* clearblue function */
void clearblue(void)
{ setfillstyle(SOLID_FILL,BLUE);
bar(3,110,637,460);
return;
}
/*************************************************/
/* savedata function */
void savedata(struct student stu_data[10])
{ FILE *fpdata;
int i;
char c=NULL;
setcolor(YELLOW);
setfillstyle(SOLID_FILL,GREEN);
bar(130,140,510,340);
setcolor(RED);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,1);
settextjustify(CENTER_TEXT,CENTER_TEXT);
outtextxy(320,190,"Do you want to Del the old Datas??");
outtextxy(320,260,"Delete? Y/else to continue");
c=getch();
if(c=='Y'||c=='y')
{unlink(d);
if((fpdata=fopen(d,"wb"))==NULL)
{outtextxy(320,220,"Cannot open data file");
outtextxy(320,250,"Please try again!!");
getch();
clearblue();
return;
}
rewind(fpdata);
for(i=0;stu_data[i].num!=0&&i<10;i++)
fwrite(&stu_data[i],sizeof(struct student),1,fpdata);
}
else
{if((fpdata=fopen(d,"ab"))==NULL)
{outtextxy(320,220,"Cannot open this file");
outtextxy(320,250,"Please try again!!");
getch();
clearblue();
return;
}
for(i=0;stu_data[i].num!=0&&i<10;i++)
fwrite(&stu_data[i],sizeof(struct student),1,fpdata);
}
fclose(fpdata);
}
/***********************************************/
/*loaddata function */
void loaddata(struct student dnote[10])
{ FILE *fpdata;
int i;
if((fpdata=fopen(d,"rb"))==NULL)
{outtextxy(320,240,"Cannot open data file");
outtextxy(320,270,"Please Input first!!!");
getch();
clearblue();
return;
}
rewind(fpdata);
for(i=0;fread(&dnote[i],sizeof(struct student),1,fpdata)!=0&&i<10;i++);
fclose(fpdata);
}
/********************************************************************/
/* savemark function */
void savemark(struct mark stu_mark[10])
{ FILE *fpmark;
int i,j,k;
char c=NULL;
float sum;
for(k=0;k<10;k++)
{sum=0;
for(j=0;j<5;j++)
sum+=stu_mark[k].court[j];
stu_mark[k].aver=sum/5.0;
}
setcolor(YELLOW);
setfillstyle(SOLID_FILL,GREEN);
bar(130,140,510,340);
setcolor(RED);
settextstyle(TRIPLEX_FONT,HORIZ_DIR,1);
settextjustify(CENTER_TEXT,CENTER_TEXT);
outtextxy(320,190,"Do you want to Del the old Marks??");
outtextxy(320,260,"Delete? Y/else to continue");
c=getch();
if(c=='Y'||c=='y')
{unlink(m);
if((fpmark=fopen(m,"wb"))==NULL)
{outtextxy(320,220,"Cannot open this file");
outtextxy(320,250,"Please try again!!");
getch();
clearblue();
return;
}
rewind(fpmark);
for(i=0;stu_mark[i].num!=0&&i<10;i++)
fwrite(&stu_mark[i],sizeof(struct mark),1,fpmark);
}
else
{if((fpmark=fopen(m,"ab"))==NULL) /*以追加的形式打开*/
{outtextxy(320,220,"Cannot open this file");
outtextxy(320,250,"Please try again!!");
getch();
clearblue();
return;
}
for(i=0;stu_mark[i].num!=0&&i<10;i++)
fwrite(&stu_mark[i],sizeof(struct mark),1,fpmark);
}
fclose(fpmark);
}
/**********************************************/
/*loadmark function */
void loadmark(struct mark mnote[10])
{ FILE *fpmark;
int i;
if((fpmark=fopen(m,"rb"))==NULL)
{outtextxy(320,240,"Cannot open mark file");
outtextxy(320,270,"Please Input first!!!");
getch();
clearblue();
return;
}
rewind(fpmark);
for(i=0;fread(&mnote[i],sizeof(struct mark),1,fpmark)!=0&&i<10;i++);
fclose(fpmark);
}
/********************************************/
void students_mark(struct mark mnote[10]) /*对分数进行输出*/
{
int i,j;
char *p[8]={"Number","Name","English","Math","Physics","Computer","C langu","Average"};
setfillstyle(SOLID_FILL,BLUE);
setcolor(YELLOW);
settextstyle(0,0,1);
bar3d(30,150,605,430,5,1);
outtextxy(200,130,"All Student Marks!!");
outtextxy(200,440,"Press any Key to Continue....");
for(i=0;i<8;i++)
{setcolor(YELLOW);
gotoxy(6+i*9,11);
puts(p[i]);
}
for(i=0;mnote[i].num!=0&&i<10;i++)
{gotoxy(6,13+i); printf("%ld",mnote[i].num);
gotoxy(6+9*1,13+i); printf("%s",mnote[i].name);
for(j=0;j<5;j++)
{gotoxy(6+9*(j+2),13+i);
printf("%.1f",mnote[i].court[j]);
}
gotoxy(6+9*7,13+i); printf("%.1f",mnote[i].aver);
}
return;
}
/***************************************/
void all_data(void)
{
int i,j;
char *p[7]={"Number","Name","Class","Sex","Age","Address","Telephone"};
struct student dnote[10];
data(dnote);
loaddata(dnote);
setcolor(YELLOW);
settextstyle(1,0,2);
outtextxy(250,130,"All Student Datas!!");
outtextxy(200,440,"Press any Key to Continue....");
setfillstyle(SOLID_FILL,BLUE);
bar3d(30,150,610,430,5,1);
for(i=0;i<7;i++)
{gotoxy(9+i*9,11);
puts(p[i]);
}
for(i=0;dnote[i].num!=0&&i<10;i++)
{gotoxy(9,13+i); printf("%ld",dnote[i].num);
gotoxy(9+9*1,13+i); printf("%s",dnote[i].name);
gotoxy(9+9*2,13+i); printf("%d",dnote[i].class);
gotoxy(9+9*3,13+i); printf("%s",dnote[i].sex);
gotoxy(9+9*4,13+i); printf("%d",dnote[i].age);
gotoxy(9+9*5,13+i); printf("%s",dnote[i].add);
gotoxy(9+9*6,13+i); printf("%ld",dnote[i].tel);
}
getch();
clearblue();
return;
}
/******************************************************/
void all_mark(void)
{struct mark mnote[10];
mark(mnote);
loadmark(mnote);
students_mark(mnote);
getch();
clearblue();
}
/*********************************************/
void subchart(void)
{ int i,x1,y1,x2,y2;
struct mark mnote[10];
mark(mnote);
loadmark(mnote);
clearblue();
setcolor(RED);
setlinestyle(0,0,1);
setfillstyle(SOLID_FILL,CYAN);
bar3d(30,148,620,388,5,1);
setcolor(WHITE);
line(40,368,600,368);
line(40,160,40,368);
line(35,165,40,160);
line(40,160,45,165);
line(595,363,600,368);
line(600,368,595,373);
line(40,168,600,168);
line(40,248,600,248);
for(i=0;mnote[i].aver!=0;i++)
{ x1=50+40*i;
y1=368-((int)mnote[i].aver)*2;
x2=70+40*i;
y2=368;
setfillstyle(SOLID_FILL,MAGENTA);
bar3d(x1,y1,x2,y2,5,1);
}
for(i=0;mnote[i].aver!=0;i++)
{ gotoxy(8+i*5,24);
printf("%ld",mnote[i].num);
}
settextstyle(0,0,1);
setcolor(YELLOW);
outtextxy(320,400,"Student Number");
outtextxy(320,135,"Average Marks");
getch();
clearblue();
return;
}
/*********************************************/
void order(void) /*从大到小排序*/
{int i,j,k;
struct mark mnote[10],temp;
mark(mnote);
loadmark(mnote);
for(i=0;mnote[i].num!=0&&i<9;i++)
{k=i;
for(j=i+1;mnote[j].num!=0&&j<10;j++)
if(mnote[j].aver>mnote[k].aver) k=j;
temp=mnote[k];
mnote[k]=mnote[i];
mnote[i]=temp;
}
students_mark(mnote);
getch();
clearblue();
}
/*****************************************************/
void searchname(void)
{char a[20];
int i,j,k,x=0,y=0;
char *p1[7]={"Number","Name","Class","Sex","Age","Address","Telephone"};
char *p2[8]={"Number","Name","English","Math","Physics","Computer","C langu","Average"};
struct student dnote[10];
struct mark mnote[10];
data(dnote);
mark(mnote);
loaddata(dnote);
loadmark(mnote);
setcolor(RED);
setfillstyle(SOLID_FILL,GREEN);
fillellipse(320,240,150,100);
settextstyle(1,0,2);
settextjustify(1,1);
outtextxy(320,200,"Input Name");
setfillstyle(SOLID_FILL,BLUE);
bar(270,222,380,246);
gotoxy(37,15);
gets(a);
clearblue();
for(i=0;dnote[i].num!=0;i++)
if(strcmp(a,dnote[i].name)==0)
{ x++;
for(j=0;j<7;j++)
{gotoxy(9+j*9,12);
puts(p1[j]);
}
gotoxy(9,14); printf("%ld",dnote[i].num);
gotoxy(9+9*1,14); printf("%s",dnote[i].name);
gotoxy(9+9*2,14); printf("%d",dnote[i].class);
gotoxy(9+9*3,14); printf("%s",dnote[i].sex);
gotoxy(9+9*4,14); printf("%d",dnote[i].age);
gotoxy(9+9*5,14); printf("%s",dnote[i].add);
gotoxy(9+9*6,14); printf("%ld",dnote[i].tel);
}
for(k=0;mnote[k].num!=0;k++)
if(strcmp(a,mnote[k].name)==0)
{ y++;
for(j=0;j<8;j++)
{
setcolor(YELLOW);
gotoxy(6+j*9,16);
puts(p2[j]);
}
gotoxy(6,18); printf("%ld",mnote[k].num);
gotoxy(6+9*1,18); printf("%s",mnote[k].name);
for(j=0;j<5;j++)
{gotoxy(6+9*(j+2),18);
printf("%.1f",mnote[k].court[j]);
}
gotoxy(6+9*7,18); printf("%.1f",mnote[k].aver);
}
if(x==0&&y==0)
{clearblue();
setcolor(YELLOW);
settextstyle(1,0,2);
settextjustify(1,1);
outtextxy(320,240,"the student is not exist!!");
}
getch();
clearblue();
}
/***************************************************/
void searchnum(void)
{int x=0,y=0;
long int a;
int i,j,k;
char tt[10];
char *p1[7]={"Number","Name","Class","Sex","Age","Address","Telephone"};
char *p2[8]={"Number","Name","English","Math","Physics","Computer","C langu","Average"};
struct student dnote[10];
struct mark mnote[10];
data(dnote);
mark(mnote);
loaddata(dnote);
loadmark(mnote);
setcolor(RED);
setfillstyle(SOLID_FILL,GREEN);
fillellipse(320,240,150,100);
settextstyle(1,0,2);
settextjustify(1,1);
outtextxy(320,200,"Input Num");
setfillstyle(SOLID_FILL,BLUE);
bar(270,222,380,246);
gotoxy(37,15);
gets(tt);
clearblue();
a=atol(tt);
for(i=0;dnote[i].num!=0;i++)
if(dnote[i].num==a)
{ x++;
for(j=0;j<7;j++)
{gotoxy(9+j*9,12);
puts(p1[j]);
}
gotoxy(9,14); printf("%ld",dnote[i].num);
gotoxy(9+9*1,14); printf("%s",dnote[i].name);
gotoxy(9+9*2,14); printf("%d",dnote[i].class);
gotoxy(9+9*3,14); printf("%s",dnote[i].sex);
gotoxy(9+9*4,14); printf("%d",dnote[i].age);
gotoxy(9+9*5,14); printf("%s",dnote[i].add);
gotoxy(9+9*6,14); printf("%ld",dnote[i].tel);
}
for(k=0;mnote[k].num!=0;k++)
if(mnote[k].num==a)
{ y++;
for(j=0;j<8;j++)
{gotoxy(6+j*9,16);
puts(p2[k]);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -