本帖最后由 jhq999 于 2022-12-18 10:27 编辑 int main()
{
int letterstart=0,charcount=0,lettermax=0,maxstart=0;
int ch=0;
while((ch=getchar())!='\n')
{
if(0x20==ch)
{
if((charcount-letterstart)>lettermax)lettermax=charcount-letterstart\
,maxstart=letterstart;
letterstart=charcount+1;
}
charcount+=1;
}
if((charcount-letterstart)>lettermax)lettermax=charcount-letterstart\
,maxstart=letterstart;
printf("%d %d",maxstart,lettermax);
}
int main()
{
char s[256]={0},*p=s,*start=p,*max=0,*maxstart=0;//Specifies the x-extent ggggggggggggg of the viewporttt
gets(s);
while(*p)
{
if(*p==0x20)
{
if((p-start)>max)max=p-start,maxstart=start-s;
start=p+1;
}
p+=1;
}
if((p-start)>max)max=p-start,maxstart=start-s;
printf("%d %d\n",maxstart+1,max);
return 0;
}
|