#include <stdio.h> #include <string.h> int temp[300]; void reset_temp(int *temp){ for(int i = 0; i<300; i++){ temp[i] = 0; } } int delete_duplicate_string(char *str, char *out, int* temp){ int count = 0; for(int i = 0; i<strlen(str); i++){ if(temp[str[i]] == 0){ out[count] = str[i]; temp[str[i]]++; count++; } } out[count] = '\0'; return count; } int main(){ char str[101]; char out[101]; fgets(str, sizeof(str), stdin); str[strcspn(str,"\n")] = '\0'; reset_temp(temp); int count = delete_duplicate_string(str, out, temp); if(count != 0){ printf("%s",out); } else{ printf("deo co cai l gi"); } return 0; }
Test Cases
Test Results
Input
programming
Expected Output
progamin