diff --git "a/homework1/\346\262\210\346\224\277\350\261\252+239500225.md" "b/homework1/\346\262\210\346\224\277\350\261\252+239500225.md" new file mode 100644 index 0000000..55c689e --- /dev/null +++ "b/homework1/\346\262\210\346\224\277\350\261\252+239500225.md" @@ -0,0 +1,93 @@ +# 第一题 +```cpp +#include +using namespace std; + +int main() { + int num1, num2, choice, result; + cout << "请输入第一个整数:"; + cin >> num1; + cout << "请输入第二个整数:"; + cin >> num2; + + cout << "请选择操作(1:加法,2:减法):"; + cin >> choice; + if (choice == 1) { + result = num1 + num2; + cout << "结果:" << num1 << " + " << num2 << " = " << result << endl; + } else if (choice == 2) { + result = num1 - num2; + cout << "结果:" << num1 << " - " << num2 << " = " << result << endl; + } + return 0; +} + +``` + +![屏幕截图 2024-09-28 150522](https://github.com/user-attachments/assets/00cce20f-24b5-4ebf-aebe-ea7dbc8a8700) + + +# 第二题 +```cpp +#include +using namespace std; + +int main() { + int num; + + cout << "请输入一个整数:"; + cin >> num; + + if (num % 2 == 0) { + cout << num << " 是偶数。" << endl; + } else { + cout << num << " 是奇数。" << endl; + } + return 0; +} + +``` + +![屏幕截图 2024-09-28 150607](https://github.com/user-attachments/assets/64a983cb-4931-480f-95b4-90ba4ad16bdf) + + + +# 第三题 +```cpp +#include +#include +#include +using namespace std; + +int main() { + srand(time(0)); + int number = rand() % 10 + 1; + int guess, attempts = 0; + cout << "我想了一个 1 到 10 之间的数字,请猜一猜:" << endl; + do { + cout << "你的猜测:"; + cin >> guess; + attempts++; + if (guess > number) { + cout << "猜大了,请再试一次。" << endl; + } else if (guess < number) { + cout << "猜小了,请再试一次。" << endl; + } + } while (guess != number); + cout << "恭喜你,猜对了!你总共猜了 " << attempts << " 次。" << endl; + return 0; +} + +``` + +![屏幕截图 2024-09-28 150645](https://github.com/user-attachments/assets/8d490bb5-725d-4394-b2a7-4f048bb5624c) + + + + + + + +warframe很好玩 + +![屏幕截图(11)](https://github.com/user-attachments/assets/633a2be0-0f53-4fad-b989-c2648bb52e79)