| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 564 人关注过本帖
标题:帮我看看如何修改来自一个业余爱好者的程序
只看楼主 加入收藏
liuqiqq
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2008-5-15
收藏
 问题点数:0 回复次数:0 
帮我看看如何修改来自一个业余爱好者的程序
#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-05-15 09:33
快速回复:帮我看看如何修改来自一个业余爱好者的程序
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.013600 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved