| 编程中国 | 业界新闻 | 技术文章 | 视频教程 | 下载频道 | 程序源码 | 个人空间 | 编程论坛
全能ASP/PHP/ASP.NET主机,支持月付专业 MSSQL 数据库空间,支持月付专业 MySQL 数据库空间,支持月付学习型 ASP/PHP/ASP.NET 主机 30元/年
高端软件开发 = 年薪十万不是梦赛孚耐:软件保护加密专家身份认证令牌USB KEY 
共有 183 人关注过本帖
标题:帮我看看如何修改来自一个业余爱好者的程序
收藏  订阅  推荐  打印
liuqiqq
Rank: 1
等级:新手上路
帖子:2
积分:120
注册:2008-5-15
帮我看看如何修改来自一个业余爱好者的程序

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<graphics.h>
#include<bios.h>
#include<dos.h>

#define STARTX 10
#define STARTY 5
#define SIZE   17

void main()
{  void initGraph();
   int lenth,i;
   char test[2000],c;
   FILE *fp;
   if((fp=fopen("d:\\tc\\a1\\tesk.txt","r"))==NULL)
    { printf("can not open\n");
      getch();
      exit(1);
    }
   i=0;
   while(!feof(fp))
    { fscanf(fp,"%c",&c);
       if(c>31)
       test[lenth=i++]=c;
     }
   fclose(fp);
   initGraph();
   cleardevice();
   setbkcolor(BLACK);
   sittesk(lenth,test);
   dotesk(lenth,test);
   closegraph();
   getch();
}

int row,col;
draw(int i,int j,char key,int color)
{ int x,y;
  char keys[2];
  keys[1]='\0';
  keys[0]=key;
  x=STARTX+j*SIZE;
  y=STARTY+i*SIZE;
  settextjustify(1,1);
  settextstyle(1,0,1);
  setcolor(color);
  outtextxy(x,y,keys);
}

sittesk(int lenth,char *test)
{ int i;
  for(i=0;i<lenth;i++)
   { row=i/(630/SIZE);
     col=i%(630/SIZE);
     draw(2*row,col,test[i],LIGHTGREEN);
   }
   
}
dotesk(int lenth,char *test)
{ int key,i,error=0;
  double x,y;
  char word,c;
  char complete[30],right[30];
  for(i=0;i<lenth;i++)
   { row=i/(630/SIZE);
     col=i%(630/SIZE);
     key=bioskey(0);
     word=key%256;
     if(word==test[i])
      draw(2*row+1,col,test[i],WHITE);
     else { draw(2*row+1,col,word,RED);
            printf("%c",7);
            error++;
          }
     if(key/256==1)
      break;
   }

   sprintf(complete,"Completion is %5.2f %",i*100.00/lenth);
   sprintf(right,"Exactitude is %5.2f %",(i-error)*100.00/lenth);
   setcolor(BROWN);
   settextjustify(1,1);
   settextstyle(3,0,2);
   outtextxy(450,430,complete);
   outtextxy(450,450,right);
   getch();
   exit(1);
}
void initGraph()
{  int gdriver=DETECT,gmode,errorcode;
   initgraph(&gdriver,&gmode,"d:\\tc");
   errorcode=graphresult();
   if(errorcode!=grOk)
     { printf("Graphics error:%s\n",grapherrormsg(errorcode));
       exit(0);
     }
}
搜索更多相关主题的帖子: 爱好者  include  业余  
2008-5-15 09:33
关于我们 | 广告合作 | 编程中国 | 清除Cookies | Archiver | WAP | TOP

编程中国 版权所有,并保留所有权利。鲁ICP备08000592号
Powered by Discuz, Processed in 0.045402 second(s), 9 queries.
Copyright©2004-2008, BCCN.NET, All Rights Reserved