求助大佬
查看原帖
求助大佬
1532475
seventeen03楼主2024/12/15 17:10
#include <stdio.h>
#include <string.h>
char longest[105],shortest[105];
char word[105];
int widest,thinnest=205,n;
int main ()
{
	scanf("%s",&shortest);
	n=strlen(shortest);
	for(int i=0;i<n;i++)
		longest[i]=shortest[i];
	thinnest=n;
    widest=n;
    for(;scanf("%s",&word)!=EOF;)
    {
        widest=strlen(longest);
        n=strlen(word);
        if(n>widest)
        {
            for(int i=0;i<n;i++)
                longest[i]=word[i];
        }
        else if(n<thinnest)
        {
        	thinnest=n;
            for(int i=0;i<thinnest;i++)
                shortest[i]=0;
            for(int i=0;i<n;i++)
            {
				shortest[i]=word[i];
			}
                
        }
    }
    printf("%s\n%s",longest,shortest);
    return 0;
}

样例以及自测无错但是提交无法通过

2024/12/15 17:10
加载中...