반응형
데이터 비교해서 sink 맞추기
1.소스
#include<string> #include<iostream> #include<vector> using namespace std; int main( int argc , char ** argv ) { vector<string> file; vector<string> memory; file.push_back("a"); memory.push_back("a"); memory.push_back("b"); vector< vector<string>::iterator > erase_data; vector<string>::iterator file_it; for( file_it = file.begin(); file_it != file.end(); file_it ++ ) { vector<string>::iterator data_it; for( data_it = memory.begin(); data_it != memory.end(); data_it ++ ) { if( (*file_it).compare( (*data_it) ) == 0 ) { }else { erase_data.push_back( data_it ); } } } vector< vector<string>::iterator >::iterator erase_it; for( erase_it = erase_data.begin(); erase_it!= erase_data.end();erase_it++) { memory.erase((*erase_it)); } vector<string>::iterator pr_it; for( pr_it = memory.begin(); pr_it != memory.end(); pr_it++ ) { cout << *pr_it << endl; } return 0; }
2.결과
hacker@HACKER:~/cpp$ hacker@HACKER:~/cpp$ g++ -o sink sink.cpp hacker@HACKER:~/cpp$ ./sink a
반응형
'C++' 카테고리의 다른 글
using for with a string (0) | 2016.07.29 |
---|---|
point to string (0) | 2016.07.29 |
pointer (0) | 2016.07.28 |
hash string (0) | 2016.07.12 |
i2string 숫자를 문자열로 변환 (0) | 2016.07.12 |