小学生c ++プログラミング情報
リンク:https
://pan.baidu.com/s/1XlA5AcjDXz5YWOFT32gSmw抽出コード:9iz9
#include <iostream> #include <ctime> // time()関数を呼び出す必要がある#include < cstdlib> // srand()関数とrand()関数 を名前空間を使用して呼び出す必要があるstd; int main() { int n、a; cout << "宝くじ" << endl; cout << "please enter 1-5:"; cin >> n; srand(time(0)); //ランダムシード a = rand()%5 + 1; / / (n == a) cout <<「おめでとう、あなたが勝った!賞金10元」<< endl;の場合、1から5までの整数をランダムに生成します。 それ以外の場合 cout <<「勝ちません、2元を支払ってください」<< endl; cout << "当選番号は" << a << endl; return 0; }