Primary school students c ++ programming information
Link: https://pan.baidu.com/s/1XlA5AcjDXz5YWOFT32gSmw
extraction code: 9iz9
#include <iostream> #include <ctime> // The time () function needs to be called # include <cstdlib> // The srand () and rand () functions need to be called using namespace std; int main () { int n, a; cout << "Lottery" << endl; cout << "please enter 1-5:"; cin >> n; srand (time (0)); // random seed a = rand ()% 5 + 1; / / Randomly generate integers from 1 to 5 if (n == a) cout << "Congratulations, you have won! Prize 10 yuan" << endl; else cout << "No winning, please pay 2 yuan" << endl; cout << "The winning number is" << a << endl; return 0; }