#include<stdio.h> |
#include<stdlib.h> |
#include<conio.h> |
#include<windows.h> |
//设置光标位置 |
void setCursorPosition( int x, int y); |
int main( void ) |
{ |
char ch1,ch2; |
int a=0; |
|
setCursorPosition(0,0); |
loop: printf ( "题目\n" ); |
printf ( "○A、选项1\n" ); |
printf ( "-------------------------------------------------------------------------------\n" ); |
printf ( "○B、选项2\n" ); |
|
do { |
ch1=getch(); |
switch (ch1){ |
case 'a' : |
case 'A' : |
setCursorPosition(0,1); |
printf ( "\b \b●" ); |
setCursorPosition(0,3); |
printf ( "\b \b○" ); |
ch2=ch1; |
break ; |
|
case 'b' : |
case 'B' : |
setCursorPosition(0,3); |
printf ( "\b \b●" ); |
setCursorPosition(0,1); |
printf ( "\b \b○" ); |
ch2=ch1; |
break ; |
|
|
case '\r' : |
if (a>0){ |
if (ch2== 'A' ||ch2== 'a' ){ |
system ( "cls" ); |
setCursorPosition(0,0); |
printf ( "恭喜你,答对了!" ); |
getch(); |
return 0;} |
|
else if (ch2== 'b' ||ch2== 'B' ){ |
system ( "cls" ); |
setCursorPosition(0,0); |
printf ( "真可惜,错了!" ); |
ch2= '0' ; |
getch(); |
printf ( "\b \b\b \b\b \b\b\ \b\b \b\b \b\b \b\b \b\b \b\b \b\b \b\b \b\b \b\b \b" ); |
goto loop; |
} |
} |
|
default : |
setCursorPosition(6,7); |
printf ( "输入错误" ); |
Sleep(500); |
printf ( "\b \b\b \b\b \b\b \b\b \b\b \b\b \b" );} |
|
a++; |
} while (1); |
return 0; |
} |
void setCursorPosition( int x, int y){ |
COORD coord; |
coord.X = x; |
coord.Y = y; |
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord); |
} |
by: 发表于:2017-08-08 11:13:10 顶(0) | 踩(0) 回复
??
回复评论