题目链接:
1 #include2 #include 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()) !='\n')10 {11 if( c == '[')//进入12 {13 while( (c=getchar()) != ']' )//退出14 {15 if(c == '\n') //读取到换行符返回 16 return (i-1);17 p[i][j] = c;18 j++;19 20 }21 p[i][j] = '\0'; 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 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 if46 (a1 < 0 || a2 < 0 || a3 < 0 || a4 < 0 || a5 < 0) 47 {48 puts("Are you kidding me? @\\/@");49 }50 else51 {52 printf("%s(%s%s%s)%s\n",hand[a1],eye[a2],mouse[a3],eye[a4],hand[a5]);53 }54 }55 56 return 0;57 }