STL map vector (indefinite length array)

Source: Internet
Author: User
Tags control characters map vector

Ah ah Ah! Remember, it should be better to read it a few times.

1#include <cstdio>2#include <iostream>3#include <string>4#include <cctype>//1.The test character ctype.h is the header file in the C standard function library, and defines a batch of C-language character classification functions (c character classification functions) to test whether a character belongs to a particular character category, such as alphabetic characters, control characters, and so on. Both single-byte characters and wide characters are supported. 5#include &LT;VECTOR&GT;//2. Indefinite long array size (); Push_back ();p ush_back ();6#include &LT;MAP&GT;//3. Mapping Good Understanding7#include <algorithm>8 using namespacestd;9 Tenmap<string,int>cnt;//!  Onevector<string>words; A  - stringRepr (Const string&s) - { the     stringans=s; -      for(intI=0; I<ans.length (); i++) -Ans[i]=tolower (Ans[i]);//4.Cctype converted to lowercase letters - sort (Ans.begin (), Ans.end ()); +     returnans; - } +  A intMain () at { -     intn=0; -     strings; -      while(cin>>s) -     { -         if(s[0]=='#') Break; in Words.push_back (s); -         stringR=repr (s); to         if(!cnt.count (R))//

The //algorithm header file defines a function of Count , which functions like find. This function uses a pair of iterators and a value to make a parameter that returns the statistical result of the number of occurrences of this value.

The writer reads a series of int data, stores them in a vector object, and then counts how many times a given value occurs .

cnt[r]=0;//map!~ +cnt[r]++; -     } thevector<string>ans; *      for(intI=0; I<words.size (); i++) $     if(Cnt[repr (words[i])]==1) Ans.push_back (Words[i]);Panax Notoginseng sort (Ans.begin (), Ans.end ()); -      for(intI=0; I<ans.size (); i++) thecout<<ans[i]<<Endl; +     return 0; A}

I just have to know the map.

STL map vector (indefinite length array)

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.