【算法笔记】B1052 卖个萌

题目链接:https://pintia.cn/problem-sets/994805260223102976/problems/994805273883951104

 1 #include <math.h>
 2 #include <stdio.h>
 3  
 4 char hand[10][5],eye[10][5],mouse[10][5];
 5  
 6 int  get_symbol(char p[][5]) //返回符号数
 7 {
 8     char c,i=0,j=0;
 9     while( (c=getchar()) !='
')
10     {
11         if( c == '[')//进入
12         {
13             while( (c=getchar()) != ']' )//退出
14             {
15                 if(c == '
') //读取到换行符返回   
16                     return (i-1);
17                 p[i][j] = c;
18                 j++;
19  
20             }
21             p[i][j] = ''; 
22             i++;
23             j=0;
24         }
25     }
26     return (i-1);
27 }
28  
29 main()
30 {
31     int hand_count,eye_count,mouse_count;
32     int n,i,a1,a2,a3,a4,a5;
33     hand_count = get_symbol(hand); //统计数量,接收符号
34     eye_count = get_symbol(eye);
35     mouse_count = get_symbol(mouse);
36     scanf("%d",&n);
37     for(i=0;i<n;i++)
38     {
39         scanf("%d%d%d%d%d",&a1,&a2,&a3,&a4,&a5);
40         //判断越界 
41         if(a1-1 > hand_count || a5-1 > hand_count || a2-1 > eye_count || a4-1 > eye_count || a3-1 > mouse_count) //注意下标越界的情况
42         {
43             puts("Are you kidding me? @\/@");
44         }
45         else if
46             (a1 < 0 || a2 < 0 || a3 < 0 || a4 < 0 || a5 < 0) 
47         {
48             puts("Are you kidding me? @\/@");
49         }
50         else
51         {
52             printf("%s(%s%s%s)%s
",hand[a1],eye[a2],mouse[a3],eye[a4],hand[a5]);
53         }
54     }
55  
56     return 0;
57 }
原文地址:https://www.cnblogs.com/chunlinn/p/10670923.html