编写一个方法,去掉一个数组的重复元素。
#include <stdio.h> #include <stdlib.h> #include <string.h> #define N 255 static int tmp[N]; void delete_duplication(char *src) { int i, j; int index; int length = strlen(src); for (i = 0; i < length; ++i) { /* code */ index = (int)(*(src + i)); tmp[index] += 1; if (tmp[index] == 1) { /* code */ printf("%c", index); } } } int main(void) { /* code */ //char str[] = "asadasddasfadsgdfggdfgsdf"; char str[] = "qwertyuiopasdfghjklzxcvbnmqwertyuiopasdfghjklzxcvbnm"; delete_duplication(str); return 0; }