-
-
Save goctave/2410435 to your computer and use it in GitHub Desktop.
CareerCup 1.3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/************************************ | |
O(n^2)的算法 | |
*************************************/ | |
#include <stdio.h> | |
#include <string.h> | |
void unique(char str[]) | |
{ | |
int len = strlen(str); | |
int i, j; | |
for(i = 0, j = 0; i < len; i++) | |
{ | |
int k = 0; | |
int flag = 0; | |
while(k <= j) | |
{ | |
if(str[k] == str[i]) | |
{ | |
flag = 1; | |
break; | |
} | |
else | |
k++; | |
} | |
if(flag) | |
continue; | |
str[++j] = str[i]; | |
} | |
str[++j] = '\0'; | |
} | |
int main() | |
{ | |
char str[100]; | |
scanf("%s", str); | |
unique(str); | |
printf("%s\n", str); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment