set 容器使用案例

// set.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include "stdafx.h"
#include<vector>
#include <iostream>
#include <set>
#include <algorithm>
#include "conio.h"
#include <string>
#include<math.h>
using namespace std;
#pragma warning (disable: 4786)
int main(int argc, char* argv[])
{
  /*  int w,n,i=0,x;
 map<int,int>m;
 vector<int>v;
 cin>>w>>n;
     while (true)
  {
   cin>>i>>x;
       if (i==0&&x==0)
      break;
     m[i]=x;
  }
  map<int,int>::iterator it;
  for(it=m.begin ();it!=m.end();it++)
  {
  
  }*/

 string a,b;
 int t=0;
   set<char> s;
 while(true){
   
 cin>>a>>b;
 set<char>::iterator it;
 for(int i=0;i<a.length();i++)
 {  
         s.insert(a[i]);
 }
 for(it=s.begin ();it!=s.end ();it++)
 {
  bool q=false;
    
   for(int j=0;j<b.length();j++)
   {
  if(*it==b[j]&&q==false)
  {
   t++;
  q=true;
  }
 } 
  
 }
 cout<<t<<endl;
 s.clear();
 }
 getch();
 return 0;
}

 

posted @ 2012-10-15 23:05  MFT  阅读(210)  评论(0编辑  收藏  举报