#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; }
时间: 2024-10-17 03:20:54