【发布时间】:2014-02-11 06:16:03
【问题描述】:
#include <iostream>
#include <cstring>
using namespace std;
int main() {
std::string a, b;
int number_cases=0,i,j,count=0;
cin>>number_cases;
while(number_cases!=0)
{
cin>>a;
cin>>b;
for(i=0;i<a.size();i++) {
for(j=0;j<b.size();j++) {
if(a[i]==b[j]); {
count++;
b[j]='#';
break;
}
}
}
cout<<count<<endl;
count=0;
--number_cases;
}
}
http://www.codechef.com/FEB14/problems/LCPESY 我在提交时遇到 TLE 错误,建议一些优化输出的方法。
【问题讨论】:
-
请不要从您的代码中删除错误,如果它们在下面的答案中进行了讨论。这会让其他人更难从你的错误中吸取教训。
-
这个问题似乎离题了,因为它缺乏最基本的理解。
标签: c++ string string-length