学了java,学了C#,真不想忘记C++ 以前记得的函数都忘记了很多。 真想快点除来工作,能熟练一样技术。 现在,太杂了。 #include<iostream> #include<ctime> using namespace std; int main() { cout<<"please enter a num<10 :"; int num; cin>>num; int right; cout<<"the happy num is: "; srand(time(0)); for(int i=0;i<10000;i++) { if(i==9999) { right=rand()%10; cout<<right<<endl; } else cout<<rand()%10<<'/b'; } if(num==right) cout<<"congratulation! you catch the right."<<endl; else cout<<"oh, sorry, you miss this time."<<endl; system("pause"); } 上面例子说明了随机数的生成,以前总是不用时间种子。。。