有奖有罚

2 条评论

  • @ 2025-6-25 13:31:37
    #include<bits/stdc++.h>
    #include<windows.h>
    using namespace std;
    int main(){
    	long long a=5;
    	system("color 2f");
    	for(int o=0;o<=5;++o){
    		printf("==抽奖游戏==\n欢迎来玩抽奖游戏!\n输入一个2000内整数一个空格一个a到m的字母\n有奖有罚!\n您有%lld次机会\n请抽奖:\n",a);
    		long long l;
    		char v;
    		cin>>l>>v;
    		for(int i=1;i<=l;++i){
    			cout<<v<<"   ";
    			Sleep(0.9999999999999986);
    			++v;
    			if(v=='n')	v='a';
    		}
    		if(v=='a')	cout<<"真挺好"<<" "<<"我讲两个笑话";
    		if(v=='b')	cout<<"运气不好"<<" "<<"大嘴巴子";
    		if(v=='c')	cout<<"运气特不好"<<" "<<"戳你的心";
    		if(v=='d'){
    			cout<<"还行"<<" "<<"再来一";
    			++a;
    		}
    		if(v=='i')	cout<<"挺好"<<" "<<"借书一天";
    		if(v=='e')	cout<<"很遗憾"<<" "<<"空";
    		if(v=='f')	cout<<"运气不好"<<" "<<"二十个蹲起";
    		if(v=='g')	cout<<"运气不好"<<" "<<"蛙跳10次";
    		if(v=='h')	cout<<"运气好"<<" "<<"看我跳舞";
    		if(v=='j')	cout<<"跳舞";
    		if(v=='k')	cout<<"运气特不好"<<" "<<"骂自己";
    		if(v=='l')	cout<<"运气不好"<<" "<<"装自己可爱";
    		if(v=='m'){
    			cout<<"还行"<<" "<<"再来一";
    			++a;
    		}
    		cout<<"\n";
    		--a;
    	}
    	cout<<"\n抽奖次数已用完,感谢参与!";
    	return 0;
    }
    //抽奖游戏 
    
    👍 1
    🤡 1
    👎 1
    😄 1
    😕 1
    ❤️ 1
    🤔 1
    🤣 1
    🌿 1
    🍋 1
    🕊️ 1
    👀 1
    • @ 2025-6-24 13:31:00
      #include<iostream>
      #include<cstdlib>
      #include<ctime>
      #include <windows.h>
      using namespace std;
      
      void functionWithoutArgs(){
          system("color 9f"); 
          char v;
          int l, n = 6; // 初始化剩余抽奖次数为6
          cout<<"欢迎来玩抽奖游戏!!!"<<endl;
          
          // 只在游戏开始时显示一次提示信息
          cout<<"有奖有罚!"<<endl;
          
          // 使用循环控制抽奖次数
          while(n > 0){
              cout<<"还可抽"<< n <<"次"<<endl ;
              cout<<"请输入抽奖次数和任意字符开始游戏(抽奖次数建议为12-372之间)"<<endl;
              
              // 验证输入的抽奖次数是否为有效整数
              while(!(cin >> l)) {
                  cout << "错误:请输入有效的整数作为抽奖次数!" << endl;
                  cin.clear();
                  cin.ignore(10000, '\n');
              }
              
              // 读取并丢弃用户输入的任意字符(原代码中读取后又重置为'a',这没有意义)
              cin >> v; 
              
              cout << "抽奖动画开始:" << endl;
              
              // 重置v为'a'开始动画效果
              v = 'a';
              for(int i = 1; i <= l; ++i){
                  ++v;
                  cout << v << "   ";
                  if(v == 'z'){
                      v = 'a';
                  }
                  Sleep(0.8); // 使用Windows API的Sleep函数
              }
              cout << endl;
              
              // 奖项判定
              cout << "=== 抽奖结果 ===" << endl;
              
              // 只在程序开始时初始化一次随机数种子
              static bool seedInitialized = false;
              if (!seedInitialized) {
                  srand(static_cast<unsigned int>(time(0)));
                  seedInitialized = true;
              }
              
              int randomNum = rand() % 100;
              
              // 奖项判定逻辑(保持原概率分布)
              if(randomNum < 1) { // 1%
                  cout << "恭喜您获得传说级大奖!!!" << endl;
                  cout << "奖品:私人太空旅行体验券!" << endl;
              } else if(randomNum < 2) { // 1%
                  cout << "恭喜您获得传说级大奖!!!" << endl;
                  cout << "奖品:豪华游艇一周使用权!" << endl;
              } else if(randomNum < 3) { // 1%
                  cout << "恭喜您获得传说级大奖!!!" << endl;
                  cout << "奖品:私人岛屿度假套餐!" << endl;
              } else if(randomNum < 5) { // 2%
                  cout << "恭喜您获得特等奖!!!" << endl;
                  cout << "奖品:豪华环球旅行套餐!" << endl;
              } else if(randomNum < 7) { // 2%
                  cout << "恭喜您获得超稀有奖!!" << endl;
                  cout << "奖品:定制黄金雕像!" << endl;
              } else if(randomNum < 9) { // 2%
                  cout << "恭喜您获得超稀有奖!!" << endl;
                  cout << "奖品:专业摄影器材套装!" << endl;
              } else if(randomNum < 11) { // 2%
                  cout << "恭喜您获得超稀有奖!!" << endl;
                  cout << "奖品:高端音响系统!" << endl;
              } else if(randomNum < 13) { // 2%
                  cout << "恭喜您获得超稀有奖!!" << endl;
                  cout << "奖品:豪华手表收藏!" << endl;
              } else if(randomNum < 16) { // 3%
                  cout << "恭喜您获得一等奖!!" << endl;
                  cout << "奖品:最新款旗舰笔记本电脑!" << endl;
              } else if(randomNum < 19) { // 3%
                  cout << "恭喜您获得一等奖!!" << endl;
                  cout << "奖品:高端游戏主机一台!" << endl;
              } else if(randomNum < 22) { // 3%
                  cout << "恭喜您获得一等奖!!" << endl;
                  cout << "奖品:最新款智能手机一部!" << endl;
              } else if(randomNum < 25) { // 3%
                  cout << "恭喜您获得二等奖!" << endl;
                  cout << "奖品:高端机械键盘套装!" << endl;
              } else if(randomNum < 28) { // 3%
                  cout << "恭喜您获得二等奖!" << endl;
                  cout << "奖品:专业无线鼠标!" << endl;
              } else if(randomNum < 31) { // 3%
                  cout << "恭喜您获得二等奖!" << endl;
                  cout << "奖品:精美手表一块!" << endl;
              } else if(randomNum < 34) { // 3%
                  cout << "恭喜您获得二等奖!" << endl;
                  cout << "奖品:智能家居套装!" << endl;
              } else if(randomNum < 37) { // 3%
                  cout << "恭喜您获得三等奖!" << endl;
                  cout << "奖品:无线降噪耳机一副!" << endl;
              } else if(randomNum < 40) { // 3%
                  cout << "恭喜您获得三等奖!" << endl;
                  cout << "奖品:智能手环一个!" << endl;
              } else if(randomNum < 43) { // 3%
                  cout << "恭喜您获得三等奖!" << endl;
                  cout << "奖品:运动背包一个!" << endl;
              } else if(randomNum < 46) { // 3%
                  cout << "恭喜您获得三等奖!" << endl;
                  cout << "奖品:蓝牙音箱一个!" << endl;
              } else if(randomNum < 49) { // 3%
                  cout << "您获得了幸运奖!" << endl;
                  cout << "奖品:100元购书券!" << endl;
              } else if(randomNum < 52) { // 3%
                  cout << "您获得了幸运奖!" << endl;
                  cout << "奖品:精美礼品卡一张!" << endl;
              } else if(randomNum < 55) { // 3%
                  cout << "您获得了幸运奖!" << endl;
                  cout << "奖品:品牌充电宝一个!" << endl;
              } else if(randomNum < 58) { // 3%
                  cout << "您获得了幸运奖!" << endl;
                  cout << "奖品:定制文具套装!" << endl;
              } else if(randomNum < 61) { // 3%
                  cout << "您获得了幸运奖!" << endl;
                  cout << "奖品:精美书籍一套!" << endl;
              } else if(randomNum < 64) { // 3%
                  cout << "您获得了普通奖..." << endl;
                  cout << "奖品:纪念徽章一枚。" << endl;
              } else if(randomNum < 67) { // 3%
                  cout << "您获得了普通奖..." << endl;
                  cout << "奖品:精美书签一套。" << endl;
              } else if(randomNum < 70) { // 3%
                  cout << "您获得了普通奖..." << endl;
                  cout << "奖品:定制明信片!" << endl;
              } else if(randomNum < 73) { // 3%
                  cout << "手气一般般..." << endl;
                  cout << "惩罚:帮朋友做一件小事!" << endl;
              } else if(randomNum < 76) { // 3%
                  cout << "手气一般般..." << endl;
                  cout << "惩罚:打扫卫生一次!" << endl;
              } else if(randomNum < 79) { // 3%
                  cout << "手气一般般..." << endl;
                  cout << "惩罚:整理房间一小时!" << endl;
              } else if(randomNum < 82) { // 3%
                  cout << "运气不太好哦..." << endl;
                  cout << "惩罚:做十道数学题!" << endl;
              } else if(randomNum < 85) { // 3%
                  cout << "运气不太好哦..." << endl;
                  cout << "惩罚:唱一首儿歌!" << endl;
              } else if(randomNum < 88) { // 3%
                  cout << "运气不太好哦..." << endl;
                  cout << "惩罚:做20个深蹲!" << endl;
              } else if(randomNum < 91) { // 3%
                  cout << "运气不太好哦..." << endl;
                  cout << "惩罚:写一篇短文!" << endl;
              } else if(randomNum < 94) { // 3%
                  cout << "非常遗憾..." << endl;
                  cout << "惩罚:给朋友讲一个冷笑话!" << endl;
              } else if(randomNum < 96) { // 2%
                  cout << "非常遗憾..." << endl;
                  cout << "惩罚:明天早起跑步!" << endl;
              } else if(randomNum < 98) { // 2%
                  cout << "非常遗憾..." << endl;
                  cout << "惩罚:完成一项小挑战!" << endl;
              } else { // 2%
                  cout << "超级倒霉!" << endl;
                  cout << "惩罚:连续三天早起!" << endl;
              }
              
              // 减少剩余抽奖次数
              n--;
              
              // 抽奖之间添加分隔线,提高可读性
              if(n > 0) {
                  cout << "\n----------------------------------------\n";
              }
          }
          
          cout << "\n抽奖次数已用完,感谢参与!" << endl;
      }
      
      int main(){
          functionWithoutArgs();
          //抽奖游戏 
          return 0;
      }
      
      
      • 1

      信息

      ID
      1202
      时间
      1000ms
      内存
      256MiB
      难度
      1
      标签
      递交数
      0
      已通过
      0
      上传者