许多游戏

病毒代码

全是地址:合集:https://blog.csdn.net/ebirth/article/details/95328792
https://blog.csdn.net/ebirth/article/details/89279857
https://blog.csdn.net/ebirth/article/details/89289191
https://blog.csdn.net/ebirth/article/details/89406594
https://blog.csdn.net/ebirth/article/details/89407353
https://blog.csdn.net/ebirth/article/details/89407353
https://blog.csdn.net/ebirth/article/details/89279690
https://blog.csdn.net/ebirth/column/info/37645

恐怖片

https://blog.csdn.net/ebirth/article/details/89280196
https://blog.csdn.net/ebirth/article/details/91345760
在这里再给四部最佳奥斯卡恐怖片:https://zhidao.baidu.com/question/93874786.html?qbpn=1_1&fr=newsearchlist&word=有恐怖片拿过奥斯卡奖的吗?

游戏代码

 #include <iostream>
  9 #include <stdlib.h>
 10 #include <time.h>
 11 #include <string.h>
 12 #include <stdbool.h>
 13
 14 void InitializeGame(void);
 15 void GetInput(char * input);
 16 bool CheckAnswer(char * input);
 17 bool GiveTips(char * input);
 18 void GetRandom(char * random);
 19 using namespace std;
 20
 21 char answer[5] = "";
 22 char input[10] = "";
 23 int times = 0;
 24
 25 int main(int argc, char** argv) {
 26     char c;
 27     while (true){
 28         cout << "Enter 'S' to start the game, 'Q' to quit." << endl;
 29         c = toupper(getchar());
 30         while(getchar() != '\n');
 31         if (c == 'Q')
 32             break;
 33         else if(c == 'S'){
 34             cout << "Game Start! Enter your answer:" << endl;
 35             times = 0;
 36             InitializeGame();//初始化游戏
 37 //            cout << "The answer is: " << answer << endl;
 38             GetInput(input); //输入猜测值
 39             //检查猜测是否正确 不正确则给出提示
 40             while(GiveTips(input) == false){
 41                 times++;
 42                 GetInput(input);
 43             }
 44             times++;
 45             cout << "Congratulations! You have got it after " << times << " times." << endl;
 46         }else
 47             cout << "Only 'S' and 'Q' are received." << endl;
 48     }
 49
 50     return 0;
 51 }
 52
 53 /******************************************************************************
 54 *函数名称:void InitializeGame(void)
 55 *函数功能:初始化游戏,生成随机数
 56 *入口参数:无
 57 *返 回 值:无
 58 *******************************************************************************/
 59 void InitializeGame(void){
 60     static bool init_rand = false;
 61     if (init_rand == false){
 62         srand ((unsigned) time(NULL)); //如果未初始化则初始化随机数种子
 63         init_rand = true;
 64     }
 65     GetRandom(answer);//生成随机数
 66 //    cout << answer << endl;
 67 }
 68
 69 /******************************************************************************
 70 *函数名称:void GetInput(char * input)
 71 *函数功能:读取一个字符串
 72 *入口参数:返回读取的字符串
 73 *返 回 值:无
 74 *******************************************************************************/
 75 void GetInput(char * input){
 76     gets(input);
 77     while(true){
 78         if(strlen(input) != 4){
 79             cout << "Please input a 4-digits number!" << endl;
 80             gets(input);
 81             continue;
 82         }
 83         if(CheckAnswer(input) == false){
 84             cout << "There couldn't be two same character in your answer!" << endl;
 85             gets(input);//不合法则重新输入
 86             continue;
 87         }
 88         break;
 89     }
 90 }
 91
 92 /******************************************************************************
 93 *函数名称:bool checkanswer(char * input)
 94 *函数功能:判断答案是否合法,即是否存在重复数字
 95 *入口参数:input为待判断的答案
 96 *返 回 值:正确则返回真,否则返回假
 97 *******************************************************************************/
 98 bool CheckAnswer(char * input){
 99     char temp[5];
100     strcpy (temp, input);
101     for(int i = 0; i < 4; i++){
102         for(int j = i + 1; j < 4; j++)
103             if(temp[i] == input[j])
104                 return false;
105     }
106     return true;
107 }
108
109 /******************************************************************************
110 *函数名称:void GiveTips(char * input)
111 *函数功能:根据输入的答案来给出提示
112 *入口参数:待判断的答案
113 *返 回 值:无
114 *******************************************************************************/
115 bool GiveTips(char * input){
116 //    cout << "I'm checking." << endl;
117     int a = 0, b = 0;
118     for(int i = 0; i < 4; i++){
119         for(int j = 0; j < 4; j++){
120 //            cout << "i:" << i << "j:" << j << endl;
121             if (input[i] == answer[j]){
122                 if(i == j)
123                     a++;
124                 else
125                     b++;
126                 continue;
127             }
128         }
129     }
130     cout << "Tips:" << a << "A" << b << "B\n" << endl;
131     if (a == 4)
132         return true;
133     cout << "Enter another answer:";
134     return false;
135 }
136
137 /******************************************************************************
138 *函数名称:void GetRandom(char * random)
139 *函数功能:产生一个各位数不相等的四位随机数
140 *入口参数:random为返回的随机数
141 *返 回 值:无
142 *备 注:先生成一个0-9的整数数组,再随机从中取四个数,每取一个将该位置为-1
143 *******************************************************************************/
144 void GetRandom(char * random){
145     int i, j[10], k;
146     for (i = 0; i < 10; i++){
147         j[i] = i;
148     }
149     for(i = 0; i < 4; i++){
150         //生成第i个随机数
151         k = (int)rand() % 10;//k为下标
152         while (j[k] == -1){
153             k = (k + 1) % 10;
154         }
155         random[i] = '0' + j[k];
156         j[k] = -1;
157     }
158 }
07-17 16:41