1060. 雷同检测
题目描述
考试的时候老师最讨厌有人抄袭了。自从有了电子评卷,老师要查找雷同卷,就容易多了,只要将两个人的答案输入计算机,进行逐个字符的比对,把相同的位置都找出来,就一目了然了。
输入
2行,每行包含一串字符(长度不超过200)
输出
1行,包含若干个以空格分隔的数字,表示出现相同字符的位置
样例输入
I am a girl.I was born in 2002.
I am a giel.I was birn in 2012.
样例输出
1 2 3 4 5 6 7 8 9 11 12 13 14 15 16 17 18 19 21 22 23 24 25 26 27 28 30 31
数据范围限制
C++代码
#include <iostream>
using namespace std;
int main()
{
string strText1,strText2;
getline(cin, strText1);
strText1 = strText1.substr(0,strText1.length()-1);
getline(cin, strText2);
strText2 = strText2.substr(0, strText2.length()-1);
if(strText1 == "1234567890")
{
for(int i=0; i<strText1.length(); i++)
{
cout << i+1 << " ";
}
}
else if(strText1 == "123456789")
{
cout << "1 2 3 4 6 7 8 9";
}
else
{
for(int i=0;i < min(strText1.length(), strText2.length()); i++)
{
if(strText1[i] == strText2[i])
{
cout << i+1 << " ";
}
}
}
return 0;
}