PAT乙级1052-----卖个萌 (20分)

1052 卖个萌 (20分)

PAT乙级1052-----卖个萌 (20分)

 

 

输入样例:

[╮][╭][o][~\][/~]  [<][>]
 [╯][╰][^][-][=][>][<][@][⊙]
[Д][▽][_][ε][^]  ...
4
1 1 2 2 2
6 8 1 5 5
3 3 4 3 3
2 10 3 9 3
 

输出样例:

╮(╯▽╰)╭
<(@Д=)/~
o(^ε^)o
Are you kidding me? @\/@

思路:
1.照着打就行
2.注意转义字符'\'输出要用"\\"

首次通过代码:
PAT乙级1052-----卖个萌 (20分)
 1 #include<stdio.h>
 2 
 3 int main(){
 4     char hand[100];int hand_sum=0;int hand1[100];
 5     char eye[100];int eye_sum=0;int eye1[100];
 6     char mouth[100];int mouth_sum=0;int mouth1[100];
 7     int sum;
 8     gets(hand);
 9     gets(eye);
10     gets(mouth);
11     int i=0;
12     while(hand[i]!='\0'){
13         if(hand[i]=='[') hand1[hand_sum++]=i+1;
14         i++;
15     }
16     i=0;
17     while(eye[i]!='\0'){
18         if(eye[i]=='[') eye1[eye_sum++]=i+1;
19         i++;
20     }
21     i=0;
22     while(mouth[i]!='\0'){
23         if(mouth[i]=='[') mouth1[mouth_sum++]=i+1;
24         i++;
25     }
26     scanf("%d",&sum);
27     for(int i=0;i<sum;i++){
28       int a,b,c,d,e;
29       scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
30       if(a>hand_sum||e>hand_sum||b>eye_sum||d>eye_sum||c>mouth_sum||a<=0||b<=0||c<=0||d<=0||e<=0) printf("Are you kidding me? @\\/@");
31       else{
32         int j=hand1[a-1];
33         while(hand[j]!=']') {
34             printf("%c",hand[j]);
35             j++;
36         }
37         printf("(");
38         j=eye1[b-1];
39         while(eye[j]!=']'){
40             printf("%c",eye[j]);
41             j++;
42         }
43         j=mouth1[c-1];
44         while(mouth[j]!=']'){
45             printf("%c",mouth[j]);
46             j++;
47         }
48         j=eye1[d-1];
49         while(eye[j]!=']'){
50             printf("%c",eye[j]);
51             j++;
52         }
53         printf(")");
54         j=hand1[e-1];
55         while(hand[j]!=']'){
56             printf("%c",hand[j]);
57             j++;
58         }
59       }
60       if(i!=sum-1) printf("\n");
61     }
62 }
View Code

 

参考:

FROM:https://blog.csdn.net/liuchuo/article/details/51994284

上一篇:1052 卖个萌


下一篇:【PAT甲级】1052 Linked List Sorting (25 分)