L1-011. A-B

题目地址:https://www.patest.cn/contests/gplt/L1-011

思路:对A串每个字符进行判断,即每个字符都与B串的字符进行比较,不再B串中,输出该字符串。

注:我用的是有相同的字符,则对A串进行移位???????,

注意点:无。

 1 #include<stdio.h>
 2 #include<string.h>
 3 int main()
 4 {
 5     char strA[105],strB[105];
 6     gets(strA);
 7     gets(strB);
 8     for(int i=0;i<strlen(strB);i++)
 9     {
10         for(int j=0;j<strlen(strA);j++)
11          {
12              if(strA[j]==strB[i]) 
13              {
14                  int k;
15                  for(k=j;k<strlen(strA);k++) strA[k]=strA[k+1];
16                  strA[k]='\0';
17              }
18          }
19     }
20     printf("%s\n",strA);
21     return 0;
22 }

 

posted @ 2018-01-18 13:12  爱你的笑  阅读(158)  评论(0编辑  收藏  举报