24: Word Length, 24: Word Length

Source: Internet
Author: User

24: Word Length, 24: Word Length
24: Word Length

  • View
  • Submit
  • Statistics
  • Question
Total time limit:
1000 ms
 
Memory limit:
65536kB
Description

Enter a word sequence. adjacent words are separated by one or more spaces. Calculate the length of each word accordingly.

Note: if there is a punctuation mark (such as a hyphen or comma), the punctuation marks are counted as part of the word that is connected to them. A string that is not separated by spaces is counted as a word.

Input
A word sequence contains at least one word and a maximum of 300 words. Each word is separated by at least one space. The total length of a word sequence cannot exceed 1000.
Output
Output the length of the corresponding word in sequence, separated by commas.
Sample Input
She was born in 1990-01-02  and  from Beijing city.
Sample output
3,3,4,2,10,3,4,7,5
 1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<cmath> 5 using namespace std; 6 char a[10001]; 7 char b[10001]; 8 int main() 9 {10     int flag=0;11     gets(a);12     int l=strlen(a);13     int tot=0;14     for(int i=0;i<l;i++)15     {16         if(a[i]!=' ')tot++;17         18         else 19         {20             if(tot!=0)21             {22                 cout<<tot<<",";23             }24             tot=0;25         }26         if(i==l-1)27             cout<<tot;28         29     }30     return 0;31 }

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.