Title: Find the first character in a string that appears only once. If you enter "Abaccdeff\0", Output ' B '. #ifndef __select_first__#define __select_first__char select_first (char *p,int size); Char select_first1 (char *p, int size); Char select_first2 (char *p, int size); #endif //header file function declaration # include<stdio.h>//function Body #include<string.h>char select_first (char arr[],int size) {int i = 0, j = 0;while (Arr[i]) {if ((arr[i] != arr[j]&& j< (size-1)) | | I==J) {j + +;} else{ j = 0;i++;} if (j == (size - 1)) return arr[i];} return ' + ';} Char select_first1 (char *p, int size) {char ch = ' + '; char arr[20];int i = 1,j=1;strcpy (arr, p);while (arr[0]) {ch = arr[0];i = 1; j = 1;while (Arr[i]) { if (Ch == arr[i]) {j + +;} Else{arr[i - j] = arr[i];} i++;} if (j == 1) return ch;arr[i - j] = ' \ n ';} return ' + ';} Char select_first2 (char p[]) {int arr[255] = { 0 };char * ptr = NULL;ptr = &p[0];while (*p) {arr[*p]++;p + +;} while (*ptr) {if (arr[*ptr] == 1) return *ptr;ptr++;} return ' + ';} #include <stdio.h> //main function # include " Select_first.h "Int main () {char arr[] = " Abbaccdeff "; Char ch=select_first2 (Arr,strlen ( ARR));p rintf ("%c\n", ch);}
C language traversal of the character array lookup method (custom header file)