cout<< "" <
cout<< x << endl;
可以用system("cls")清屏,然后while(1)判断有没有输入空格键就行了
#include <iostream>
#include <stdlib.h>
#include <conio.h>
using namespace std;
int main(){
int mode=0;//用于判断现在是*(0)还是X(1)
cout<<"*";
while (1){
char ch=_getch();//无缓冲接收输入信息
if (ch==' '){//如果ch是空格键
system("cls");
if (mode==0){
cout<<"X";
mode=1;
}else{
cout<<"*";
mode=0;
}
}
}
}
这是我的方法,看看能不能运行