Submission
Status:
[PPPPPPPP]
Subtask/Task Score:
{100/100}
Score: 100
User: winkawin2552
Problemset: สตริงซ้ำซ้ำ
Language: c
Time: 0.001 second
Submitted On: 2025-10-10 09:43:18
#include <stdio.h>
void sort_word(char word[]){
for(int i = 0; word[i]!= '\0'; i++){
char key = word[i];
int j = i-1;
while(j>=0 && word[j] > key){
word[j+1] = word[j];
j--;
}word[j+1] = key;
}
}
int in(char word[], char target){
for(int i= 0; word[i] != '\0'; i++){
if(word[i] == target) return 1;
}return 0;
}
int main() {
char word1[30];
char word2[30];
scanf("%s", word1);
scanf("%s", word2);
sort_word(word2);
char temp = word2[0];
if(in(word1, temp)) printf("%c ", temp);
for(int i =1; word2[i] != '\0'; i++){
if(word2[i] != temp && in(word1, word2[i])){
printf("%c ", word2[i]);
temp = word2[i];
}
}
return 0;
}