其他分享
首页 > 其他分享> > A - 雷同检测

A - 雷同检测

作者:互联网

题目描述:
考试的时候老师最讨厌有人抄袭了。自从有了电子评卷,老师要查找雷同卷,就容易多了,只要将两个人的答案输入计算机,进行逐个字符的比对,把相同的位置都找出来,就一目了然了。

输入格式
22 行,每行包含一串字符(长度不超过 200200)。

输出格式
11 行,包含若干个以空格分隔的数字,表示出现相同字符的位置。

输入示例:
I am suantoujun.
I am huayemei.
输出示例:
1 2 3 4 5 6 8 9

#include<stdio.h>
#include<string.h>
int main()
{
    char str1[201],str2[201];
    gets(str1);
    gets(str2);
    int len1,len2;
    len1=strlen(str1);
    len2=strlen(str2);
    
    int i,j=0;
    int x[201];
    for(i=0; i<len1; i++){
        if(str1[i]==str2[i]){
            x[j]=i+1;
            j++;
        }
    }

    for(i=0; i<j; i++){
        printf("%d ",x[i]);
    }


    getchar();
    getchar();
    return 0;
}

标签:201,字符,示例,int,检测,str1,雷同,str2
来源: https://blog.csdn.net/qq_64873060/article/details/122375426