Hdu_2072 _ count the number of words _ set _ detection string

Source: Internet
Author: User

Hdu_2072 _ count the number of words _ set _ detection string

 

Train of Thought: input a line of words to check the number of different words

The key lies in two points: ① do not repeat words ② pay attention to spaces

Self-Use As a set, the first point has been removed. Then, use sstream (see www.bkjia.com) to remove spaces and count.

The Code is as follows:

 

# Include

 
  
# Include

  
   
# Include

   
    
// Set version # include

    
     
Using namespace std; const int maxn = 1000; set

     
      
Dic; int main (void) {string s; while (getline (cin, s) {dic. clear (); // if (s = #) break; stringstream ss; ss. str (s); string buf; while (ss> buf) dic. insert (buf); cout <

      
        Solve the problem by using a normal processing string as follows: 
       

 

 

Related Article

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.