cquhx


私信TA

用户名:cquhx

访问量:3420

签 名:

等  级
排  名 3643
经  验 1804
参赛次数 1
文章发表 6
年  龄 0
在职情况 学生
学  校 重庆大学
专  业

  自我简介:

菜鸟一只,求带

TA的其他文章

解题思路:将要改变的地方标记起来;

重新用两个字符数组来比较

注意事项:要使用getchar来缓冲掉输入单词后出现的换行符

参考代码:

#include <stdio.h>

#include <string.h>


int strcp(char s1[],char s2[])

{

        int i;

        char s3[20], s4[20];

        strcpy(s3, s1);

        strcpy(s4, s2);

        i = 0;

        while (s3[i] != '\0')

        {

            if ('a' <= s3[i] && 'z' >= s3[i])

                s3[i] -= 32;

                i++;

        }

        i = 0;

        while (s4[i] != '\0')

        {

            if ('a' <= s4[i] && 'z' >= s4[i])

            s4[i] -= 32;

            i++;

        }

        if (strcmp(s3, s4) == 0)

            return 1;

        return 0;

}

int main()

{

    char s[20][1000], s1[10000], s3[20];

    int n, i, lenth, j, start, end, k, l;

    scanf("%d", &n);

    for (i = 0; i < n; i++)

        scanf("%s", &s[i]);

    getchar();

    while (gets(s1) != NULL)

    {

        lenth = strlen(s1);

        for (i = 0; i < lenth; i++)

        {

            start = i;

            l = 0;

            while (s1[i] != ' '&&s1[i] != '\0')

            {

                s3[l] = s1[i];

                l++;

                i++;

            }

            s3[l] = '\0';

            end = i - 1;

            for (j = 0; j < n; j++)

            {

                if (strcp(s[j], s3))

                {

                    for (k = start + 1; k <= end; k++)

                    {

                         s1[k] = '*';

                    }

                }

           }

        }

        puts(s1);

    }

}


 

0.0分

1 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区