type pdf c语言课程设计,c语言课程设计6典型小程序.pdf

典型小程序典型小程序 1 读取 读取 DBF 文件文件 READDBF C 1 2 读取文件中整数并排序 读取文件中整数并排序 filetest c 2 3 鼠标应用 鼠标应用 mousetes c 3 4 画图 画图 painttes c 5 5 文件系统中目录内容显示 文件系统中目录内容显示 dirtest c 9 6 链表插入操作 链表插入操作 list c 9 1 1 读取dbf文件 readdbf c 读取 dbf 文件指定记录范围的详细 include int rf k reclen addr p1 long brec erec i j recnum p2 unsigned char buf 4096 pbuf 81 FILE fp main int argc char argv if argc 1 printf Usage n exit 0 fp fopen argv 1 rb if fp NULL printf s can not open n argv 1 exit 0 fread buf 1 32 fp p1 int buf p2 long buf p2 recnum p2 p1 4 addr p1 p1 reclen p1 if argc 2 rf 0 brec 1 erec recnum if argc 3 rf atoi argv 2 brec 1 erec recnum if argc 4 rf atoi argv 2 brec atoi argv 3 erec recnum 2 if argc 5 rf atoi argv 2 brec atoi argv 3 erec atoi argv 4 fseek fp long addr 32 1 for i 1 i brec for j 0 j reclen for k 0 k 80 pbuf k buf j pbuf 80 0 printf s pbuf printf n fclose fp 2 读取文件中整数并排序 filetest c 读取文件中整数并排序 include void sort int list int n int i j next for i 1 i 0 j list j 1 list j list j 1 next main int input 10 i FILE fpin fpout 3 if fpin fopen in dat r NULL printf Can not open file in dat n exit 1 for i 0 i 10 i fscanf fpin d fread input sizeof int 10 fpin sort input 10 if fpout fopen out dat w NULL printf Can not open file in n exit 1 for i 0 i 10 i fprintf fpout d input i fwrite input sizeof int 10 fpout printf n 3 鼠标应用 mousetes c 鼠标应用 include define ON 1 define OFF 2 define LEFTBUTTON 1 define RIGHTBUTTON 2 define BOTHBUTTON 3 int haveMouse 0 int resetMouse union REGS r r x ax 0 int86 0 x33 haveMouse r x ax return haveMouse 0 0 r x bx void lightMouse int op 4 union REGS r if haveMouse r x ax op int86 0 x33 int getMouseStatus int x int y union REGS r if haveMouse r x ax 3 int86 0 x33 x r x cx y r x dx return r x bx else return 0 void setMouseXY int x int y union REGS r if haveMouse r x ax 4 r x cx x r x dx y int86 0 x33 void setMouseRange int left int top int right int bottom union REGS r if haveMouse r x ax 7 r x cx left r x dx right int86 0 x33 5 r x ax 8 r x cx top r x dx bottom int86 0 x33 main int button x y n if n resetMouse printf No Mouse n exit 0 else printf yes d n n lightMouse ON setMouseRange 50 50 100 100 do button getMouseStatus if button LEFTBUTTON printf LEFTBUTTON n else if button RIGHTBUTTON printf RIGHTBUTTON n while button BOTHBUTTON lightMouse OFF 4 画图 painttes c 简单的画图程序 include include include define ON 1 define OFF 2 define LEFTBUTTON 1 define RIGHTBUTTON 2 define BOTHBUTTON 3 int haveMouse 0 int resetMouse 6 union REGS r r x ax 0 int86 0 x33 haveMouse r x ax return haveMouse 0 0 r x bx void lightMouse int op union REGS r if haveMouse r x ax op int86 0 x33 int getMouseStatus int x int y union REGS r if haveMouse r x ax 3 int86 0 x33 x r x cx y r x dx return r x bx else return 0 void setMouseXY int x int y union REGS r if haveMouse r x ax 4 r x cx x r x dx y int86 0 x33 7 void setMouseRange int left int top int right int bottom union REGS r if haveMouse r x ax 7 r x cx left r x dx right int86 0 x33 r x ax 8 r x cx top r x dx bottom int86 0 x33 int mouseIn int mx int my int x int y int width int height return mx x main int mode VGAHI int driver VGA int color WHITE int fillcolor WHITE int x y button i initgraph rectangle 0 429 639 479 moveto 10 440 outtext Line Color moveto 10 460 outtext Fill Color for i 0 i 16 i rectangle 100 i 25 435 124 i 25 475 setfillstyle 1 i bar 101 i 25 436 123 i 25 474 8 line 100 455 499 455 moveto 505 440 setcolor 1 outtext Linewidth 1 bar 600 435 630 455 moveto 505 460 setcolor 2 outtext Linewidth 3 bar 600 456 630 476 setcolor WHITE resetMouse lightMouse ON while 1 button getMouseStatus if button LEFTBUTTON if mouseIn x y 0 429 639 50 if mouseIn x y 100 435 400 20 color x 100 25 setcolor color if mouseIn x y 100 455 400 20 fillcolor x 100 25 setfillstyle 1 fillcolor if mouseIn x y 600 435 30 20 setlinestyle 0 0 1 outtext 1 if mouseIn x y 600 456 30 20 setlinestyle 0 0 3 outtext 3 if mouseIn x y 550 456 75 14 outtext out break else lightMouse OFF lineto x y lightMouse ON 9 else if button RIGHTBUTTON lightMouse OFF setviewport 0 0 639 428 1 floodfill x y color setviewport 0 0 639 479 1 lightMouse ON else if button BOTHBUTTON break else moveto x y closegraph 5 文件系统中目录内容显示 dirtest c 文件系统中目录内容显示 include include main struct ffblk ffblk int done printf Directory listing of c with odd size n done findfirst c while done if ffblk ff fsize 2 printf s ld n ffblk ff name ffblk ff fsize done findnext 6 链表插入操作 list c 关于链表操作 从小到大插入 include include main 10 int n i data struct node int data struct node next head NULL p q1 q2 scanf d for i 0 idata data q1 NULL q2 head while q2 NULL q2 q2 next p next q2 if q1 NULL q1 next p else head p for p head p NULL p p next printf d p data

展开阅读全文

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值