harumakigohan686

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

这里先埋个坑(

#CP1025. 陈述句变成疑问句

还是有点小bug后面再调吧

#include <stdio.h>
#include <ctype.h>
#include <string.h>
int main()
{
    char a[100];
    char b[100]; //第一个单词
    char c[100]; //第二个单词
    char d[100]; //其余剩下的单词
    int i,y,x,f,j=0,k=0,l=0;
    gets(a);
    f=strlen(a);
    for(i=0; a[i]!='\0'; i++)
    {
        b[j]=a[i];
        j++;
        if(a[i+1]==' ')
        {
            break;
        }
    }
    b[j]='\0';
    if(i==f)
    {
        for(int t=0; t<j-1; t++)
        {
            printf("%c",b[t]);
        }
        printf("?");
        return 0;
    }
    for( y=i+1; a[y]!='\0'; y++)
    {
        c[k]=a[y];
        k++;
        if(a[y+1]==' ')
        {
            break;
        }
    }
    c[k]='\0';
    if(f==y)
    {
        for(int t=0; t<k-1; t++)
        {
            if(c[t]!=' ')
            {
                if(t==1)
                {
                    printf("%c",c[t]-32);
                    continue;
                }
                printf("%c",c[t]);
            }
        }
        printf(" ");
        for(int t=0; t<j; t++)
        {
            if(b[t]!=' ')
            {
                if(t==0)
                {
                    printf("%c",b[t]+32);
                    continue;
                }
                printf("%c",b[t]);
            }
        }
        printf("?");
        return 0;
    }
    for( x=y+1; a[x]!='\0'; x++)
    {
        d[l]=a[x];
        l++;
        if(a[x+1]=='\0')
        {
            break;
        }
    }
    d[l]='\0';
    for(int t=0; t<k; t++)
    {
        if(c[t]!=' ')
        {
            if(t==1)
            {
                printf("%c",c[t]-32);
                continue;
            }
            printf("%c",c[t]);
        }
    }
    printf(" ");
    for(int t=0; t<j; t++)
    {
        if(b[t]!=' ')
        {
            if(t==0)
            {
                printf("%c",b[t]+32);
                continue;
            }
            printf("%c",b[t]);
        }
    }
    for(int t=0; t<l-1; t++)
    {
        printf("%c",d[t]);
    }
    printf("?");
    return 0;
}

posted on   harumakigohan  阅读(16)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· C#/.NET/.NET Core技术前沿周刊 | 第 29 期(2025年3.1-3.9)
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
点击右上角即可分享
微信分享提示