C++控制台模拟"骇客帝国数字飞屏"

2014-11-24 12:03:41 · 作者: · 浏览: 0

#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"< flag=1;
}else{
cout<<"0"< flag=0;
}
}
}
if(z==rowNo){
colNo=10+rand()%50;
rowNo=10+rand()%50;
z=0;
}
}

cout<<">GameOver<"< //暂停屏幕
cin.get();
}
简单的代码实现,要点:随机数 的生成方法。。


摘自 完美科技