代码如下,昨天晚上没事写着玩的 没有啥技术含量 只要把逻辑思路捋清就可以了  重点还是在研究通讯录上

 1 #include<stdio.h>
 2 #include<stdlib.h>
 3 #include<time.h>
 4 #include<windows.h>
 5 int main()
 6 {    int x;
 7     int y;
 8     int mouse_x;
 9     int mouse_y;
10     int hit_x;
11     int hit_y;
12     int hang,lie;
13     int nums = 0;
14     int numlose = 0;
15     int numwin = 0;
16     int times;
17     int chang;
18     int kuan;
19     Sleep(10000);
20     printf("欢     迎     来      打      地    鼠!\n");
21     printf("游戏版权归cyc所有\n");
22     printf("----------------------------------------\n");
23     Sleep(1000);
24     printf("\n\n\n\n");
25     printf("请输入局数:    ");
26     scanf("%d",&times);
27     printf("请输入地图大小(提示:大小必须小于十位数):\n");
28     printf("长:    ");
29     scanf("%d",&chang);
30     printf("宽:    ");
31     scanf("%d",&kuan);
32 
33     printf("游戏即将开始!\n");
34     Sleep(3000);
35     printf("START!\n");
36     while(nums != times)
37     {    
38         if(nums + 1 == times)
39             printf("还剩最后一局,把握机会\n");
40         srand(time(0));
41         mouse_x = rand()%3+1;
42         mouse_y = rand()%3+1;
43         for(hang = 1; hang <= kuan ;hang ++)
44         {
45                 for(lie = 1; lie <= chang ;lie++)
46             {
47                 if((mouse_x == hang)&&(mouse_y == lie))
48                     printf("");
49                 else
50                     printf("");
51             }
52             printf("\n");
53         }
54         printf("请输入击打位置(行 列):    ");
55         scanf("%d %d",&hit_x,&hit_y);
56         for(hang = 1; hang <= kuan ;hang ++)
57         {
58                 for(lie = 1; lie <= chang ;lie++)
59             {
60                 if((hit_x == mouse_x)&&(hit_y==mouse_y))
61                 {
62                     if((mouse_x == hang)&&(mouse_y == lie))
63                         printf("");
64                     else
65                         printf("");
66                 }
67                 else
68                 {
69                     if((mouse_x == hang)&&(mouse_y == lie))
70                         printf("");
71                     else if((hit_x == hang)&&(hit_y == lie))
72                         printf("");
73                     else 
74                         printf("");
75                 }
76             }
77             printf("\n");
78         }
79         Sleep(1000);
80         if((hit_x == mouse_x)&&(hit_y==mouse_y))
81         {
82             printf("恭喜您,击打成功!!!\n");
83             numwin++;
84         }
85         else
86         {
87             printf("没关系,下次努力喔!!!\n");
88             numlose++;
89         }
90         nums++;
91         printf("\n\n");
92     }
93     printf("GAME OVER\n");
94     printf("最终成绩为  共%d局  赢%d局  输%d局\n",times,numwin,numlose);
95     return 0;
96 }

2019-04-22 22:25:07 小菜鸟反思,大佬勿喷,谢谢!!!

posted on 2019-04-22 22:26  coding小菜鸟  阅读(394)  评论(0编辑  收藏  举报