c语言leave函数 c语言len函数的使用方法

打字练习软件 C语言程序#include "stdio.h"
#include "time.h"
#include "stdlib.h"
#include "conio.h"
#include "dos.h"
#define xLine 70
#define yLine 20
#define full 100
#define true 1
#define false 0
/*---------------------------------------------------------------------*/
void printScreen(int level,int right,int sum,char p[yLine][xLine])/* 刷新屏幕的输出图像 */
{
int i,j;
clrscr();
printf("level:%dPress 0 to exit;1 to pausescore:%d/%d\n",level,right,sum);/* 输出现在的等级c语言leave函数,击中数和现在已下落总数 */
printf ("----------------------------------------------------------------------\n");
for (i=0;iyLine;i++)
{
for(j=0;jxLine;j++)
printf ("%c",p[i][j]);
printf("\n");
}/* for (i) */
printf ("----------------------------------------------------------------------\n");
}/* printScreen */
/*---------------------------------------------------------------------*/
void leave()/* 离开程序时c语言leave函数 , 调用该函数结束程序 。*/
{
clrscr();
printf ("\n\n\n\nThank you for playing.");
delay (2500);
exit (0);
}
/*----------------------------------------------------------------------*/
int levelChoice(int level)/* 进入游戏时选择游戏等级 */
{
while (true)/* void */
{
clrscr ();
printf("please input 1-9 to choice level.choice 0 to return.\n");
level=getch();
level=level-48;
if (level0level10) return (level);
else if (level==0)
leave ();
else
printf ("Please input a correct number!\n");
}/* while (true) */
}/* levelChoice */
/*---------------------------------------------------------------------*/
int newWord(int sum,char p[yLine][xLine])/* 随生成一个新的字符并将其加入数组的首行 */
{
int j,w;
if (sum!=full)
{
j=(rand()%(xLine-2))+1;
w=(rand()%26)+65;
p[0][j]=w;
return (++sum);
}/* if */
return (sum);
}/* newWord */
/*---------------------------------------------------------------------*/
int moving(int miss,char p[yLine][xLine])/* 将最后一行置空c语言leave函数 , 并使所有在数组中其c语言leave函数他行的字符下降一行 */
{
int i,j;
char w;
for (j=1,i=yLine-1;jxLine-1;j++)/* 遍历最后一行的所有字符,如果该字符非空则将其置空并使miss加一 */
{
if (p[i][j]!=' ')
{
miss++;
p[i][j]=' ';
}
}
for (i=yLine-2;i=0;i--)/* 从倒数第二行的最后一个字符开始开始向前遍历该数组内的元素,如果该位置非空则将该字符移动至下一行 */
{
for (j=xLine-2;j0;j--)
{
if (p[i][j]!=' ')
{
w=p[i][j];
p[i][j]=' ';
p[i+1][j]=w;
}/* if */
}/* for(j) */
}/* for(i) */
return (miss);
}/* moving */
/*---------------------------------------------------------------------*/
int wordHit(char p[yLine][xLine])
/*判断是否有字符从键盘键入 。
如果有,则从最后一行的最后一个元素开始遍历该数组,找出该字符,并把对应位置置空,且返回1 。
如果有输入 , 但屏幕上无对应项,或无输入则返回0*/
{
int i,j;
char key;
if(kbhit())/* 判断用户是否从键盘键入字符 。如果kbhit返回值为 */
key=getch();
if(key)
{
if (key=='0') leave();
if (key=='1')
{
clrscr();
printf ("Press any key to continue.");
getch();
}
for (i=yLine;i0;i--)
{
for (j=xLine;j0;j--)
{
if (key-32==p[i-1][j-1])
{
p[i-1][j-1]=' ';
return (true);

推荐阅读