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 |
ole~~call for help T_T#include<iostream> using namespace std; int comp(const void *a, const void *b) { return *(char *)a - *(char *)b; } void main() { char a[1010], b[1010]; int alp[26]; int lena, lenb, i; while(1) { gets(a); if( 0 == strlen(a) ) break; gets(b); qsort(b,strlen(b),sizeof(b[0]),comp); memset(alp,0,sizeof(alp)); lena = strlen(a); lenb = strlen(b); for( i = 0; i < lena ; i++ ) { if( a[i] >= 'a' && a[i] <= 'z' ) alp[a[i]-'a']++; } for( i = 0 ; i < lenb; i++ ) { if( b[i] >= 'a' && b[i] <= 'z' && alp[b[i]-'a'] > 0 ) { alp[b[i]-'a']--; cout<<b[i]; } } cout<<endl; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator