#include "stdafx.h" #include<set> #include<string> #include<iostream> using namespace std; int main() { set<string> s; char buf[1000]={0}; gets(buf); char* p=buf; while(*p!=0) { if(*p==',' || *p=='.') { *p=' '; } p++; } p=strtok(buf," "); while(p!=NULL) { string tmp=p; if(s.find(tmp)==s.end()) { cout<<tmp<<" "; s.insert(tmp); } p=strtok(NULL," "); } cout<<endl; return 0; }
原文地址:http://blog.csdn.net/cjc211322/article/details/39255889