This file contains hidden or 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; |
This file contains hidden or 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
#include <stdio.h> | |
#include <string.h> | |
void exchange(char str[]) | |
{ | |
int len = strlen(str); | |
char *beg, *end; | |
char temp; | |
beg = str; | |
end = str + len - 1; |
This file contains hidden or 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
/************************************************** | |
1.最简单的方法就是两层循环,复杂度O(n^2) | |
2.使用排序,然后找重复。复杂度为O(nlgn)+O(n)=O(nlgn) | |
3.直接使用快排,在排序过程中,如果发现有重复的,立即结束递归 | |
****************************************************/ | |
#include <stdio.h> | |
#include <string.h> | |
int repeat; |
NewerOlder