5-26 單詞長度 (15分)


#include <iostream>
#include <sstream>
#include <cstring>
#include <map>
#include <stdio.h>
#include <algorithm>
using namespace std;

int main()
{
   string str1;
   getline(cin,str1);
   int len=str1.size();
   str1[len-1]=' ';
   istringstream it(str1);
   string word;
   int c=0,length;
   while(it >> word)
   {
       length=word.size();
       if(c==0) printf("%d",length);
       else printf(" %d",length);
       c=1;

   }
   return 0;
}


發佈了73 篇原創文章 · 獲贊 25 · 訪問量 6萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章