以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 C/C++编程思想 』  (http://bbs.xml.org.cn/list.asp?boardid=61)
----  各位大侠,帮小弟分析一C程序  (http://bbs.xml.org.cn/dispbbs.asp?boardid=61&rootid=&id=25230)


--  作者:ycj888
--  发布时间:12/10/2005 2:57:00 PM

--  各位大侠,帮小弟分析一C程序
#include<time.h>
main()
{
int x,y,i,j;
unsigned int Timer  为什么定义这
char ch;
char key;
char *kb[]={"Q W E R T Y U I O P [ ]","A S D F G H J K L ; '","Z X C V B N M , . /"};
long AllCounter=0,RightCounter=0,FalseCounter=0;
time_t t;  ?
int fun_Esc();

srand((unsigned)time(&t));?
clrscr();
gotoxy(18,1);
printf("%s\n",kb[0]);
gotoxy(20,3);
printf("%s\n",kb[1]);
gotoxy(22,5);
printf("%s\n",kb[2]);
gotoxy(11,25);
for(i=0;i<60;i++)
{
printf("=");
}
gotoxy(1,1);
printf("AllCh: %ld\nRight: %ld\nFalse: %ld",AllCounter,RightCounter,FalseCounter);
printf("\n\n");
printf("Esc to exit");
printf("\n");
printf("Enter to pause");
gotoxy(26,12);
printf("* * * * * * * * * * * * * * *");
gotoxy(26,13);
printf("* Press any key to start! *");
gotoxy(26,14);
printf("* * * * * * * * * * * * * * *");
gotoxy(51,13);
if(getch()==27)
{
if(fun_Esc()==1)
{
clrscr();
exit(0);
}
}
gotoxy(23,12);
printf(" ");
gotoxy(23,13);
printf(" ");
gotoxy(23,14);
printf(" ");
lab_start:
y = 6;为什么是6
Timer = 100000;这一是干什么
i = rand()%3;?
j = rand()%(12-i);?
ch = kb[i][j*4];??
x = 18+i*2+j*4;?
while(y<=24)?为什么是24
{
if(kbhit())
{
key = getch();
if(key==ch || key==ch+32)
{
ch = '*'; Timer = 1000;
}
else if(key==27)
{
if(fun_Esc()==1)
{
clrscr();
exit(0);
}
}
else if(key=='\r')
{
gotoxy(x,y-1);?
printf(" ");
gotoxy(28,13);
printf("Press any key to continue");
getch();
gotoxy(28,13);
printf(" ");
}
else
{
FalseCounter++;
}
}
if(y>6)?
{
gotoxy(x,y-1);
printf(" ");
}
gotoxy(x,y);
printf("%c",ch);
gotoxy(1,1);
printf("AllCh: %ld\nRight: %ld\nFalse: %ld",AllCounter,RightCounter,FalseCounter);
delay(Timer);
y++;
}
AllCounter++;
if(ch == '*')
{
RightCounter++;
}
goto lab_start;
}

int fun_Esc()
{
int key = '#';
gotoxy(24,12);
printf("* * * * * * * * * * * * * * * * *");
gotoxy(24,13);
printf("* Are you sure to exit? (Y/N) *");
gotoxy(24,14);
printf("* * * * * * * * * * * * * * * * *");
gotoxy(51,13);

while(key!='Y' && key!='y' && key!='N' && key!='n')?
{
key = getch();
if(key=='Y' || key=='y')
{
return 1;
}
if(key=='N' || key=='n')
{
gotoxy(24,12);
printf(" ");
gotoxy(24,13);
printf(" ");
gotoxy(24,14);
printf(" ");
return 0;
}
}
小弟刚学C,望大侠们多多指点


--  作者:ycj888
--  发布时间:12/11/2005 5:13:00 PM

--  
怎么不能啊,小弟在此再求各位大侠了
--  作者:firstway
--  发布时间:12/12/2005 10:34:00 AM

--  
简单说几点:
time_t t; 以_ t结尾的这些数据类型被称为原始系统数据类型。它们通常在头文件< s y s / t y p e s . h >中定
义(头文件< u n i s t d . h >应已包括该头文件)。它们通常以C typedef说明加以定义。t y p e d e f说明在C
语言中已超过1 5年了(所以这并不要求ANSI C),它们的目的是阻止程序使用专门的数据类型
(例如i n t , s h o r t或long) 来允许对于一种特定系统的每个实现选择所要求的数据类型。
一般time_t相当于long

srand((unsigned)time(&t));
i = rand()%3;
参见:http://www.ieee.org.cn/dispbbs.asp?boardID=61&ID=24994

ch = kb[i][j*4];??
x = 18+i*2+j*4;?
这样的解读要对这个程序要干什么怎么干要了解
可是这里很多函数好像是自己定义的,没有源码,而且连个注释也没有啊
我就不费力去猜猜猜啦!!!!


W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
46.875ms