不重复地输出升序数组中的元素。
1 void outputUnique( char [] str, int n) {
2 if (n <= 0 ) return ;
3 elseif(n == 1 ) putchar(str[ 0 ]);
4 else {
5 int i = 0 ,j = 1 ;
6 putchar(str[ 0 ]);
7 while (j < n) {
8 if (str[j] !== str[i]) {
9 putchar(str[j]);
10 i = j;
11 }
12 ++ j;
13 }
14 }
15 }
2 if (n <= 0 ) return ;
3 elseif(n == 1 ) putchar(str[ 0 ]);
4 else {
5 int i = 0 ,j = 1 ;
6 putchar(str[ 0 ]);
7 while (j < n) {
8 if (str[j] !== str[i]) {
9 putchar(str[j]);
10 i = j;
11 }
12 ++ j;
13 }
14 }
15 }