Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
wrong answer !!!!this is my code but i dont know why take wrong :( please help me or give me a sample input to check my code. #include <cstdio> #include <string> #include <vector> #include <algorithm> using namespace std; /////////////////////////////////////////////////////////////////////// int main() { /* freopen("input.txt", "r", stdin);*/ char buffer[100]; vector<string> v1, v2, vResult; bool flag; while ( true ) { v1.clear(); v2.clear(); vResult.clear(); while ( scanf("%s", buffer) != EOF ) { if ( !strcmp(buffer, "#") ) break; v1.push_back( buffer ); } while ( scanf("%s", buffer) != EOF ) { if ( !strcmp(buffer, "#") ) break; v2.push_back( buffer ); } flag = true; if ( v1.empty() ) break; for (vector<string>::const_iterator citr = v1.begin(); citr != v1.end(); ++citr) { if ( count(v2.begin(), v2.end(), *citr) >= 1 && find(vResult.begin(), vResult.end(), *citr) == vResult.end() ) { if ( !flag ) printf( " " ); flag = false; vResult.push_back( *citr ); printf("%s", citr->c_str()); } } printf( "\n" ); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator