[ Source Code ]#include <stdio.h>
#include <string.h>
int main ( void ) {
int check[26], check2[26], loop, input1_len; int input2_len;
char input1[1001], input2[1001];
while ( gets ( input1 ) ) {
gets ( input2 );
input1_len = strlen ( input1 );
input2_len = strlen ( input2 );
// 변수 초기화
memset ( check, 0, sizeof ( check ) );
memset ( check2, 0, sizeof ( check2 ) );
// 첫번째 인풋에서 있는 문자열 체크
for ( loop = 0 ; loop < input1_len ; loop++ ) {
check[input1[loop]-‘a’] += 1;
}
// 두번째 인풋에서 있는 문자열 체크
for ( loop = 0 ; loop < input2_len ; loop++ ) {
check2[input2[loop]-‘a’] += 1;
}
for ( loop = 0 ; loop < 26 ; loop++ ) {
while ( check[loop] && check2[loop] ) {
printf ( “%c“, (char) loop + ‘a’ );
check[loop]–;
check2[loop]–;
}
}
printf ( “\n“ );
memset ( input1, 0, sizeof ( input1 ) );
memset ( input2, 0, sizeof ( input2 ) );
}
return 0;
}
|
댓글 남기기