用c语言完成信息录入功能,如何用C语言完成学生信息输入输出模块?是高手的就帮帮忙了...

匿名用户

1级

2007-07-02 回答

/*主程序功能模块—-文件名:student.c*/

#define MAX_BAR 4 /*最大菜单数,可以自定*/

#include"io.h"

#include"dos.h"

#include"fcntl.h"

#include"stdio.h"

#include"stdlib.h"

#include"math.h"

#include"graphics.h"

#include"chi_asc.c" /*调用图形模式下汉字、字符共显功能*/

#include"public.c" /*按键定义功能*/

#include"mypcx.c" /*封面图象调用功能,此处为pcx图象*/

#include"stu_frame.c" /*框架绘制功能*/

#include"stu_sub.c" /*各子菜单功能*/

main()

{

/*old_bar、curr_bar表示上次选中的菜单、当前选中的菜单*/

/*old_sonbar curr_sonbar表示上次选中的子菜单、当前选中的子菜单*/

int i,key,key_son,old_bar,curr_bar,curr_sonbar,old_sonbar,size;

int save_startx,save_starty,save_endx,save_endy,sonbar_out=0;

void *buf;

int Driver,Mode;

char *pcx;

struct student_bar{

int start_x,start_y; /*起始横坐标,起始纵坐标*/

int length_x,length_y; /*菜单的长,菜单的宽*/

int num_son; /*包含子菜单的个数*/

char *p_father; /*菜单项名,*p_son[5]为子菜单名*/

char *p_son[5];}stu_bar[MAX_BAR]={

{10,45,120,25,4,"File Operation",{" Open file"," New file"," Save file","Exit system"}},

{130,45,120,25,3,"Data Edition",{" Add object","Delete object","Modify object"}},

{250,45,120,25,0,"File Print",{""}},

{370,45,120,25,0,"Help Message",{""}}

};/*定义各功能菜单的结构体*/

pcx="stusys4.pcx";

Set_Video_Mode(VGA256); /*转换屏幕到320*200*256色*/

PCX_Load_Screen(pcx,1); /*读取封面图象stusys4.pcx*/

Driver=DETECT,Mode=0;

initgraph(&Driver,&Mode,""); /*设置图象模式*/

cleardevice();

main_frame(BLUE,LIGHTGRAY); /*绘制主框架图,底色为蓝色*/

/*绘制菜单*/

for(i=0;i

{

setcolor(BLUE);

rectangle(stu_bar[i].start_x, stu_bar[i].start_y, stu_bar[i].start_x+stu_bar[i].length_x, stu_bar[i].start_y+stu_bar[i].length_y);

puthz16(stu_bar[i].start_x+8,stu_bar[i].start_y+5,-8,BLUE,stu_bar[i].p_father);

}puthz16(stu_bar[0].start_x+8,stu_bar[0].start_y+5,-8,WHITE,stu_bar[0].p_father);

old_bar=0;curr_bar=0;

/*读取按键字符,如为ESC则退出*/

while((key=specialkey())!=ESC){

old_bar=curr_bar;

if(sonbar_out==1)sonbar_out=0;

if(key==LEFT){

if(curr_bar==0)curr_bar=3;

else curr_bar=curr_bar-1;

}/*LEFT finished*/

if(key==RIGHT){

if(curr_bar==3)curr_bar=0;

else curr_bar=curr_bar+1;

}/*RIGHT finished*/

/*如按键为ENTER,则绘制子菜单*/

if(key==ENTER){

save_startx=stu_bar[curr_bar].start_x;

save_starty=stu_bar[curr_bar].start_y+stu_bar[curr_bar].length_y+1;

save_endx=stu_bar[curr_bar].start_x+stu_bar[curr_bar].length_x;

/*保存子菜单展开后掩盖住的图象*/ save_endy=stu_bar[curr_bar].start_y+stu_bar[curr_bar].length_y+stu_bar[curr_bar].num_son*stu_bar[curr_bar].length_y+1;

size=imagesize(save_startx,save_starty,save_endx,save_endy);

if(size!=-1)

{

buf=malloc(size);

if(buf)getimage(save_startx,save_starty,save_endx,save_endy,buf);

else {printf("OUT MEMORY");exit(0);}

}

setviewport(save_startx,save_starty,save_endx,save_endy,1);

setcolor(WHITE);

clearviewport();

for(i=1;i<=stu_bar[curr_bar].num_son;i++)

{

rectangle(0,0,stu_bar[curr_bar].length_x,i*stu_bar[curr_bar].length_y);

setfillstyle(SOLID_FILL,LIGHTGRAY);

floodfill(stu_bar[curr_bar].length_x-1,i*stu_bar[curr_bar].length_y-1,WHITE);

}

for(i=0;i

puthz16(8,i*stu_bar[curr_bar].length_y+5,-8,BLUE,stu_bar[curr_bar].p_son[i]);

puthz16(8,5,-8,WHITE,stu_bar[curr_bar].p_son[0]);

old_sonbar=0;curr_sonbar=0;

if(stu_bar[curr_bar].num_son)

while(((key_son=specialkey())!=ESC)&&sonbar_out==0){

old_sonbar=curr_sonbar;

if(key_son==UP){

if(curr_sonbar==0) curr_sonbar=stu_bar[curr_bar].num_son-1;

else curr_sonbar=curr_sonbar-1;

}

if(key_son==DOWN){

if(curr_sonbar==(stu_bar[curr_bar].num_son-1)) curr_sonbar=0;

else curr_sonbar=curr_sonbar+1;

}

puthz16(8,old_sonbar*stu_bar[curr_bar].length_y+5,-8,BLUE,stu_bar[curr_bar].p_son[old_sonbar]);

puthz16(8,curr_sonbar*stu_bar[curr_bar].length_y+5,-8,WHITE,stu_bar[curr_bar].p_son[curr_sonbar]);

if(key_son==ENTER){

setviewport(0,0,639,479,1);

putimage(save_startx,save_starty,buf,COPY_PUT);

free(buf);

sonbar_out=1;

if(curr_bar==0)

switch(curr_sonbar){

case 0:

fil_open(); /*调用stu_sub.c文件中fil_open()函数,打开文件*/

break;

case 1:

fil_new(); /*调用stu_sub.c文件中fil_new()函数,新建文件*/

break;

case 2:

fil_save(); /*调用stu_sub.c文件中fil_save()函数,保存文件*/

break;

case 3:

sys_exit(); /*调用stu_sub.c文件中sys_exit()函数,退出系统*/

}

if(curr_bar==1)

switch(curr_sonbar){

case 0:

dat_add(); /*调用stu_sub.c文件中dat_add()函数,添加记录*/

break;

case 1:

dat_dele(); /*调用stu_sub.c文件中dat_dele()函数,删除记录*/

break;

case 2:

dat_mod(); /*调用stu_sub.c文件中dat_mod()函数,修改记录*/

break;

}

} /*key_son=ENTER finished*/

}/*key_son all finished*/

if(sonbar_out==0){

setviewport(0,0,639,479,1);

putimage(save_startx,save_starty,buf,COPY_PUT);

free(buf); /*还原子菜单掩盖住的图象,并释放子菜单所占用的内存*/

}

/*如果子菜单项为0*/

if(!stu_bar[curr_bar].num_son){

if(curr_bar==2)

fil_prn(); /*调用stu_sub.c文件中fil_prn()函数,打印文件*/

if(curr_bar==3)

hel_mess(); /*调用stu_sub.c文件中hel_mess()函数,显示帮助信息*/

}

} /*ENTER finished*/

puthz16(stu_bar[old_bar].start_x+8,stu_bar[old_bar].start_y+5,-8,BLUE,stu_bar[old_bar].p_father);

puthz16(stu_bar[curr_bar].start_x+8,stu_bar[curr_bar].start_y+5,-8,WHITE,stu_bar[curr_bar].p_father);

}/*key all finished*/

fcloseall(); /*关闭所有文件*/

closegraph(); /*关闭图形状态*/

}

自己改改!!!

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值