跳到主要內容

發表文章

精選

終極密碼 in C++

#include <iostream> #include <cstdlib> #include <ctime> using namespace std; /* run this program using the console pauser or add your own getch, system("pause") or input loop */ int main(int argc, char** argv) { int input; int password; int low=1,high=100;                    //設定亂數範圍 srand((unsigned)time(NULL));   //以時間做為亂數種子 password=rand()%high+low;          cout<<"Please enter number between 1~100"<<endl; while(cin>>input){ if(input<password){ cout<<"Larger!"<<endl; low=input; cout<<"Please enter number between"<<low<<"~"<<high<<endl;} if(input>password){ cout<<"Smaller!"<<endl; high=input; cout<<"Please enter number between"<<low<<"~"<<high<<endl;} if(input==password){ cout<<"NiceWork!"; break;} } return 0; } 使用較為直觀...

最新文章

Windows10 DevC++輸出中文亂碼問題

a003兩光法師占卜術