tft每日頭條

 > 生活

 > c語言速通

c語言速通

生活 更新时间:2024-07-26 06:10:14

c語言速通?C語言-模拟金山打字通詳解#include <stdio.h>,今天小編就來聊一聊關于c語言速通?接下來我們就一起去研究一下吧!

c語言速通(C語言-模拟金山打字通詳解)1

c語言速通

C語言-模拟金山打字通詳解

#include <stdio.h>

#include <time.h>

#include <stdlib.h>

#include <conio.h>

#include <windows.h>

char*arr[]={"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 , . "};

void GamePosition(int x,int y)//1.定坐标

{

HANDLE hout = GetStdHandle(STD_OUTPUT_HANDLE);//2.給你一張白紙

COORD pos={x,y};//3.點的結構體,初始化坐标x和y 确定坐标

SetConsoleCursorPosition(hout,pos);//4.設置控制平台光标位置

}

void play()

{

int x,y,i,j;//x,y是坐标==往下掉的坐标,i,j是數組的行和列==确定随機哪個字母

char ch;//用來接收随機産生的字母

char cur;//用來接收按下的鍵盤字母

srand((unsigned)time(0));//随機種子

i=rand()%3;//行從0-2的随機數

j=rand()%(9-i);//列的随機數

ch=arr[i][j*4];//随機産生的字母

x=18 i*2 j*4;//自定義從18開始

y=7;

while(y<=19)

{

if(kbhit())//如果按下鍵盤

{

cur=getch();

if(cur==ch||cur==ch 32)

ch = ' ';

}

if(y>7)//去尾巴

{

GamePosition(x,y-1);

printf(" ");

}

GamePosition(x,y);

printf("%c",ch);

Sleep(100);

y ;

}

}

int main()

{

system("cls");

GamePosition(18,2);

printf("%s\n",arr[0]);

GamePosition(20,4);

printf("%s\n",arr[1]);

GamePosition(22,6);

printf("%s\n",arr[2]);

GamePosition(11,20);

printf("==================================");

while(1)

play();

return 0;

更多C語言技術關注 "ITjob遠标培訓"

,

更多精彩资讯请关注tft每日頭條,我们将持续为您更新最新资讯!

查看全部

相关生活资讯推荐

热门生活资讯推荐

网友关注

Copyright 2023-2024 - www.tftnews.com All Rights Reserved