新增了kbhit()函数
使游戏时更流畅:
#ifndef SOMETHING_H
#define SOMETHING_H
#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
void ycgb() {
CONSOLE_CURSOR_INFO cursor;
cursor.bVisible = FALSE;
cursor.dwSize = sizeof(cursor);
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorInfo(handle, &cursor);
return ;
}
#endif
using namespace std;
int toint(double a) {
return ((int)(a*10+5))/10;
}
void ys(double x) {
for(int i=1; i<=100000010*2.5*x; i++) {}
}
void SlowDisplay(char *p) {
while(1) {
if(*p!=0) printf("%c",*p++);
else break;
ys(0.02);
}
}
void Setpos(double x,double y) {
COORD pos;
pos.X=toint(y*2),pos.Y=toint(x);
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),pos);
}
void Color(int a) {
if(a==-1) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_GREEN|FOREGROUND_BLUE);
if(a==-2) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN);
if(a==-3) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED);
if(a==0) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),FOREGROUND_INTENSITY|FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE);
if(a==1) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_RED);
if(a==2) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_INTENSITY|BACKGROUND_RED);
if(a==3) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_GREEN);
if(a==4) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_INTENSITY|BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_BLUE);
if(a==5) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_RED|BACKGROUND_BLUE);
if(a==6) SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),BACKGROUND_BLUE);
}
int tot=1,num=100,jb,fhd,sjq,m,x,x1[5];
string xx;
bool flag=false,root=false,game=false;
string str;
void gj() {
system("shutdown -s -t 1");
}
void zt() {
system("pause");
}
void qp() {
system("cls");
}
void huan() {
flag=true;
}
int zhuan(int l,int r,string ing) {
int sum=0;
l--,r--;
for(int i=l; i<=r; i++) sum=sum*10+int(ing[i])-48;
return sum;
}
void h() {
int mam=0;
while(++mam!=1) {
system("color 1");
system("color 2");
system("color 3");
system("color 4");
system("color 5");
system("color 6");
system("color 7");
system("color 8");
system("color 9");
system("color 10");
system("color 11");
system("color 12");
system("color 13");
system("color 14");
system("color 15");
system("color 16");
system("color 17");
system("color 18");
system("color 19");
system("color 20");
}
}
void djs() {
system("color 4");
ys(1);
qp();
cout<<"关机倒计时开始:"<<endl;
ys(1);
qp();
h();
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" ************"<<endl;
cout<<" ***"<<endl;
cout<<" ***"<<endl;
cout<<" ************"<<endl;
cout<<" ***"<<endl;
cout<<" ***"<<endl;
cout<<" ************"<<endl;
ys(1);
h();
qp();
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" ************"<<endl;
cout<<" ***"<<endl;
cout<<" ***"<<endl;
cout<<" ************"<<endl;
cout<<" *** "<<endl;
cout<<" *** "<<endl;
cout<<" ************"<<endl;
ys(1);
h();
qp();
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<" ****** "<<endl;
cout<<" ** ** "<<endl;
cout<<" ** ** "<<endl;
cout<<" ** "<<endl;
cout<<" ** "<<endl;
cout<<" ** "<<endl;
cout<<" ************"<<endl;
ys(1);
h();
if(!flag&&!root) gj();
else qp(),cout<<"游戏失败!"<<endl,zt(),game=true;
}
void pt() {
qp();
srand(time(0));
while(tot!=7) {
int sum;
srand(time(0));
memset(x1,67,sizeof x1);
printf("第%d轮:请输入一个1-%d之间的数\n\n",tot,num);
if(tot==1) system("color 1"),x1[1]=rand()%num+1,x1[2]=rand()%num+1,x1[3]=rand()%num+1,x1[4]=rand()%num+1,sum=5;
if(tot==2) system("color 2"),x1[1]=rand()%num+1,x1[2]=rand()%num+1,x1[3]=rand()%num+1,x1[4]=rand()%num+1,sum=5;
if(tot