求助!C语言输出结果不知道为什么多了一个空行
查看原帖
求助!C语言输出结果不知道为什么多了一个空行
1176543
WZX20050614楼主2023/11/7 21:34
#include<stdio.h>
#include<string.h>

int main()
{
    char str[100],b[100][101],t;
    int i,len,word=0,count=-1,j;
    gets(str);
    len=strlen(str);
    for(i=0;i<len;i++)
    {
        if(str[i]==' ')
        {
            word=0;
        }
        else
        {
            if(word==0)
            {
                word=1;
                count++;
                j=0;

            }
            b[count][j]=str[i];
            j++;

        }
    }
    for(i=0;i<=count;i++)
    {
        for(j=0;j<strlen(b[i])/2;j++)
        {
            t=b[i][j];
            b[i][j]=b[i][strlen(b[i])-1-j];
            b[i][strlen(b[i])-1-j]=t;
        }
    }
    for(i=0;i<=count;i++)
    {
        puts(b[i]);
    }

    return 0;
}

2023/11/7 21:34
加载中...