#include
#include
#include
using namespace std;
int main(int argc,char* argv[]){
srand((unsigned)time(NULL));//设置种子
int colNo=10+rand()%50; //生成随机数
int rowNo=10+rand()%50;
int flag=0;
system("color 0C");//设置字体颜色
for(int z=0;z<=rowNo;z++){
for(int i=0;i<=colNo;i++){
cout<<" ";
if(i==colNo){
if(0==flag){
cout<<"1"<
}else{
cout<<"0"<
}
}
}
if(z==rowNo){
colNo=10+rand()%50;
rowNo=10+rand()%50;
z=0;
}
}
cout<<">GameOver<"<
cin.get();
}
简单的代码实现,要点:随机数 的生成方法。。
摘自 完美科技