本題要求你計算A-B。不過麻煩的是,A和B都是字符串 —— 即從字符串A中把字符串B所包含的字符全刪掉,剩下的字符組成的就是字符串A-B。
輸入格式:
輸入在2行中先后給出字符串A和B。兩字符串的長度都不超過104,并且保證每個字符串都是由可見的ASCII碼和空白字符組成,最后以換行符結束。
輸出格式:
在一行中打印出A-B的結果字符串。
輸入樣例:
I love GPLT! It's a fun game!
aeiou
輸出樣例:
I lv GPLT! It's fn gm!
代碼:
#include <iostream>
#include <string>
using namespace std;
int main()
{
bool flag = true;
char a[10005];
char b[10005];
gets(a);
gets(b);
for(int i=0;a[i]!='\0';i++)
{
flag=true;
for(int j=0;b[j]!='\0';j++)
{
if(a[i]==b[j]) flag=false;
}
if(flag) cout<<a[i];
}
cout<<endl;
return 0;
}
分析:沒什么可以分析的。。。java一直超時實在沒辦法。。。 如果有用java做出來的指點一下我就好了