1149:最长单词2

//前面做过最长和最短的单词了,再做这个就轻松多了

#include
#include
#include
using namespace std;
char ch[2501];
int main()
{
    int len,i,cnt=0,max=-1,max_op;
        memset(ch,0,sizeof(ch));
    gets(ch);
    len=strlen(ch);
    for(i=0;i     {
        if(ch[i]!=' '&&ch[i]!='.')
            cnt++;
        else
        {
            if(cnt>0)
            {
                if(cnt>max)
                {
                    max=cnt;
                max_op=i-cnt;
                }
                cnt=0;
            }

        }
                        
    }
    for(i=max_op;i     cout<     return 0;    
}

你可能感兴趣的:(1149:最长单词2)