|
![]() | 作者: flyfalcon [flyfalcon]
![]() |
登录 |
其中有很多地方得修改,呵呵,学了两个月了 总要做点什么来玩玩啊 这是主文件 main.c 是开始菜单选项界面 #include "write.c" #define UP 0x4800 #define DOWN 0x5000 #define ENTER 0x1c0d #define ESC 0x11b void Main_window(int l1, int l2) { int i,j=2,k=2; int b=205,b1=186; int a=187,a1=188; int c=200,c1=201; textattr(14+(0<<4)); clrscr(); gotoxy(1,1); printf("%c",c1); for (i=3; i<=l1; i++) {printf("%c",b);} printf("%c",a); for (i=0; ;i++) {gotoxy(1,k); printf("%c",b1); k++; if (k==l2) break;} gotoxy(1,l2); printf("%c",c); for (i=3; i<=l1; i++) {printf("%c",b);} printf("%c",a1); for (i=0; ;i++) {gotoxy(l1,j); printf("%c",b1); j++; if (j==l2) break;} } contral() { int ch; int win_y=2; gotoxy(2,win_y); do { switch(ch=bioskey(0)) { case UP:{ win_y=win_y-1; gotoxy(6,win_y); if(win_y<=2)win_y=2; break;} case DOWN:{ win_y=win_y+1; textattr(4+(1<<4));clreol(); gotoxy(6,win_y); if(win_y>=8)win_y=8; break;} case ENTER:{ window(1,1,80,25); clrscr(); retu(win_y-1); } default:{ gotoxy(2,win_y); break; } } print(); gotoxy(2,win_y); textattr(12+(2<<4)); clreol(); if(win_y<=7) { gotoxy(6,win_y); printf("%d:text%d.txt %c",win_y-1,win_y-1,186); gotoxy(2,win_y); } else { gotoxy(6,8); printf("Do it youself! %c",186); gotoxy(2,8); } }while(ch!=ESC); } print() { int win_y; for(win_y=2;win_y<8;win_y++) { gotoxy(2,win_y); textattr(14+(0<<4)); clreol(); gotoxy(6,win_y); printf("%d:text%d.txt %c",win_y-1,win_y-1,186); } gotoxy(2,win_y); textattr(14+(0<<4)); clreol(); gotoxy(6,win_y); printf("Do it youself %c",186); } main() { int win_x,win_y; textbackground(3); clrscr(); window(3,2,76,13); textbackground(2); clrscr(); Main_window(74,12); gotoxy(28,3); printf("English Practice"); gotoxy(20,4); printf("Copyright Anglic Emprie 2003-2006"); gotoxy(19,6); printf("The Maple of leaf is red as before!"); gotoxy(18,8); cprintf("Producer:\nWu wei, Maple Ocean, He Zhi Feng!"); gotoxy(10,11); printf("QQ:16972433 E-mail:gumda-z@163.com"); window(1,1,80,25); window(20,15,60,23); textbackground(3); clrscr(); Main_window(41,9); gotoxy(4,1); printf("Please select:"); gotoxy(4,1); print(); contral(); getch(); } 这是文本图形模式 window.c #include "stdio.h" #include "string.h" #include "conio.h" #include "stdlib.h" #include "dos.h" #include "bios.h" #define ESC 0x11b #define BS 0xe08 void Xwindow(void) { int i,j=2,k=2; int b=205,b1=186; int a=187,a1=188; int c=200,c1=201; textattr(14+(0<<4)); clrscr(); gotoxy(1,1); printf("%c",c1); for (i=3; i<=79; i++) {printf("%c",b);} printf("%c",a); for (i=0; ;i++) {gotoxy(1,k); printf("%c",b1); k++; if (k==25) break;} gotoxy(1,25); printf("%c",c); for (i=3; i<=79; i++) {printf("%c",b);} printf("%c",a1); for (i=0; ;i++) {gotoxy(79,j); printf("%c",b1); j++; if (j==25) break;} /* gotoxy(30 ,1); printf("English Practice");*/ gotoxy(33,25); printf("ESC -> QUIT"); } void WINDOW(void) { int x=3,y=2,z=77,t=24; int i,j=2,k=2,u=4; int h,h1; int b=205,b1=186; int a=187,a1=188; int c=200,c1=201; char strg; Xwindow(); window(x,y,z,t); textbackground(3); textcolor(15); clrscr(); gotoxy(1,1); printf("%c",c1); for (i=2; i<=74; i++) {printf("%c",b);} printf("%c",a); for (i=0; ;i++) {gotoxy(1,k); printf("%c",b1); k++; if (k==23) break;} gotoxy(1,23); printf("%c",c); for (i=2; i<=74; i++) {printf("%c",b);} printf("%c",a1); for (i=0; ;i++) {gotoxy(75,j); printf("%c",b1); j++; if (j==23) break;} gotoxy(28,1); printf("Enlish Practice"); gotoxy(20,23); printf("COPYRIGHT Anglic Emprie 2003-2006"); window(5,3,75,23); textbackground(2); clrscr(); } 这是系统显示文本 输入文本及比较 write.c #include "time.h" #include "dos.h" #include "window.c" #include "retu.c" cmp(char *ch1, char *ch2) { int con=0,cz=0; for(cz=0;cz<79;cz++) { if(ch1[cz]==ch2[cz]) { con++; } if(ch1[cz]=='\0')break; } return(con); } sfile(int s) { FILE *fp; time_t t1,t2; char strch[7][80],cha[80],filename[100]; char name[11]; int right=0 ,all=0,score; int i=0,j,z,x=3,y=2,xx=0; window(1,1,80,25); clrscr(); switch(s) { case 1: strcpy(filename,"text1.txt"); break; case 2: strcpy(filename,"text2.txt"); break; case 3: strcpy(filename,"text3.txt"); break; case 4: strcpy(filename,"text4.txt"); break; case 5: strcpy(filename,"text5.txt"); break; case 6: strcpy(filename,"text6.txt"); break; case 7: window(18,9,62,14); textbackground(0); clrscr(); gotoxy(8,2); printf("Please input file name and path: "); gotoxy(8,3); gets(filename); window(1,1,80,25); break; default : window(18,9,62,14); textbackground(0); clrscr(); gotoxy(8,2); printf("ERROR! NO SELECT !"); gotoxy(8,4); printf("MAPE OF MAPLE OCEAN!"); getch(); return (0); } if((fp = fopen(filename,"r"))==NULL) { printf("ERROR! Cannot open file!"); getch(); exit(0); } for(i=0;i<6;i++) { if(fgets(strch[i],68,fp)==NULL)break; } fclose(fp) ; /*textcolor(YELLOW); textbackground(BLUE);*/ clrscr(); WINDOW(); gotoxy(x,y); for(z=0;z<i;z++) { for(j=0;j<67;j++) { if(strch[z][j]=='\n')break; putchar(strch[z][j]); if(strch[z][j]=='\0') break; } gotoxy(x,y=y+3); /* if(j==78)gotoxy(x,y=y+3);*/ } t1=time(NULL); x=3; y=3; gotoxy(x,y); for(z=0;z<i;z++) { for(j=0;j<79;j++) { textattr(YELLOW+(GREEN<<4)); clreol(); if(wherex()>=70) { gotoxy(x=3,y=y+3); break; } cha[j]=bioskey(0); putchar(cha[j]); if(j==77)gotoxy(3,y=y+2); x++;xx=0; switch(cha[j]) { case 8: x-=2; if(x<3) { x=3; } gotoxy(x,y); putchar(' '); gotoxy(x,y-2); putchar(' '); gotoxy(x,y); if(j<=0) if(j%2==0) j=j+1; else j+=2; j-=2; break; case 27: x-=1; gotoxy(x,y); putchar(' '); gotoxy(x,y); goto end; case 13: gotoxy(x,y=y+1); putchar('\n'); y+=2; x=3; strch[z][j]='\0'; gotoxy(x,y); j=79; xx=1; break; } if(cha[j]==strch[z][j]) { gotoxy(x-1,y=y-2); putchar(' '); gotoxy(x,y=y+2); } else { if(xx!=1&&cha[j]!=8) { if(x>3) { gotoxy(x-1,y-2); /*putchar(strch[z][j]);*/ textattr(128+12+(2<<4)); clreol(); putchar(25); gotoxy(x,y); } } } } all=all+strlen(strch[z]) ; strcpy(filename,strch[z]); right=right+cmp(filename,cha); } t2=time(NULL); /*clrscr();*/ score=(int)difftime(t2,t1); window(18,9,62,14); textbackground(0); clrscr(); /*fill();*/ gotoxy(3,3); printf("Right Total Accurate Rate Speed"); gotoxy(4,5); printf("%d %d %.2f %.2f",right,all,(float)(right)/(all)*100,(float)(all)/(score-5)*10); getch(); /*retu();*/ return 0; end: return(0); } 这是其它选项及显示界面 retu.c retu(int rnd) { char ch; int temp=1; printf("%d",rnd); sfile(rnd); while(1) { window(1,1,80,25); window(20,10,60,13); textbackground(3); clrscr(); gotoxy(4,2); printf("Do you want pratice?(Y/N)"); gotoxy(4,3); /* rnd++; if(rnd>=9) rnd=1;*/ rnd=(rand()/10000+rand()/10000)+1; if(temp==rnd) { rnd=rnd+1; temp=rnd; } ch=getche(); if(ch=='Y' || ch=='y') { sfile(rnd); } else if(ch=='N' || ch=='n') { exit (0); } } } |
地主 发表时间: 11/18 15:56 |
![]() | 回复: ceo_8008 [ceo_8008] ![]() |
登录 |
up~~~ 路过,不错,比我们好多了 |
B1层 发表时间: 11/18 18:04 |
![]() | 回复: wangdong11 [wangdong11] ![]() |
登录 |
注释太少,让人怎么看!一个好的程序应该有三分之一以上是注释! |
B2层 发表时间: 11/18 18:35 |
![]() | 回复: flyfalcon [flyfalcon] ![]() |
登录 |
不好意思,那我得改一下,不过现在没时间了, 对不起,大家啦。 |
B3层 发表时间: 11/18 18:43 |
![]() | 回复: 286 [unique] ![]() |
登录 |
不错,非常好. |
B4层 发表时间: 11/19 09:14 |
![]() | 回复: flyfalcon [flyfalcon] ![]() |
登录 |
谢了,,286, 呵呵,我后来加了注释了,只不过,在学校的机房里,没上网,不能发上来,等找个机会,把它发上来。。。。。。。 我现在一直也找不到灵感,做个什么好程序玩玩,,,版主,能不能给我指个方向啊, [此贴被 枫叶依红(flyfalcon) 在 11月19日19时45分 编辑过] |
B5层 发表时间: 11/19 19:06 |
![]() | 回复: de987 [de987] ![]() |
登录 |
比我强!因我不会写程序! |
B6层 发表时间: 11/21 09:53 |
![]() | 回复: 286 [unique] ![]() |
登录 |
从长远来说,一个是网络,一个是数据库。 |
B7层 发表时间: 11/21 12:29 |
![]() | 回复: flyfalcon [flyfalcon] ![]() |
登录 |
谢了,版主啊 |
B8层 发表时间: 11/21 14:03 |
|
20CN网络安全小组版权所有
Copyright © 2000-2010 20CN Security Group. All Rights Reserved.
论坛程序编写:NetDemon
粤ICP备05087286号