标签:pre ios pac stack clu size tor tin mes
输出一句话中最短和最长的单词
#include<iostream> #include<queue> #include<vector> #include<stack> #include<algorithm> #include<cmath> #include<set> #include<cstring> using namespace std; int main(){ char str[20202]; cin.getline(str,20010); int len=strlen(str); string maxn="",minn=""; int max_len=-9999; int min_len=9999; for(int i=0;i<len;i++) { string fz=""; for(int j=i;j<len&&str[j]!=‘ ‘&&str[j]!=‘,‘;j++,i++) { fz+=str[j]; } if(fz.size()>max_len) { max_len=fz.size(); maxn=fz; } if(fz.size()==0) continue; if(fz.size()<min_len) { min_len=fz.size(); minn=fz; } } cout<<minn<<endl; return 0; }
标签:pre ios pac stack clu size tor tin mes
原文地址:https://www.cnblogs.com/fangzheng-nie/p/9946020.html