Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h>
- #include <time.h>
- using namespace std;
- void Start();
- void GetResults();
- int i, j, life, maxrand;
- char c;
- void Start() {
- i = 0;
- j = 0;
- life = 0;
- maxrand = 6;
- cout << "選擇遊玩難度:\n";
- cout << "1 : 簡單 (0-15萬)\n";
- cout << "2 : 中等 (0-30萬)\n";
- cout << "3 : 困難 (0-50萬)\n";
- cout << "輸入其他鍵以離開\n";
- c = 30;
- cin >> c;
- cout << "\n";
- switch (c) {
- case '1':
- maxrand = 150000;
- break;
- case '2':
- maxrand = 300000;
- break;
- case '3':
- maxrand = 500000;
- break;
- default:
- exit(0);
- break;
- }
- life = 5;
- srand((unsigned)time(NULL));
- j = rand() % maxrand;
- GetResults();
- }
- void GetResults() {
- if (life <= 0) {
- cout << "輸了 笑你爛 哈哈哈!\n\n";
- Start();
- }
- cout << "輸入數字: \n";
- cin >> i;
- if((i>maxrand) || (i<0)) {
- cout << "數字不在0~\n" << maxrand;
- GetResults();
- }
- if(i == j) {
- cout << "踩到狗屎猜到了!\n\n";
- Start();
- } else if(i>j) {
- cout << "太大了 不要\n";
- life = life - 1;
- cout << "殘餘生命: " << life << "\n\n";
- GetResults();
- } else if(i<j) {
- cout << "太小了 討厭\n";
- life = life - 1;
- cout << "殘餘生命: " << life << "\n\n";
- GetResults();
- }
- }
- int main() {
- cout << "冷冷好愛你的遊戲\n";
- cout << "給我猜數字啦\n";
- cout << "我很好心告樹你數字是否太大或太小\n";
- cout << "但你可能還是笨到猜不出來\n\n";
- Start();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement