Algorithm increase 11-2 Delete repeating element time limit: 10.0s memory limit: 256.0MBThe problem is described as the library design new function Delpack, which deletes all the repeating elements in the input string. Discontinuous repeating elements are also removed.
A function is required, and a pointer operation is used inside the function. Sample input 1223445667889 Sample output 13579 sample input else sample output LS data size and convention string array maximum length is 100.
1 /*2 Ideas:3 The string is stored in the character array A, and the value is copied to array B, and each element of B is traversed4 The corresponding element in B is set to-1, compared to each element in a. 5 An element in output B that is not-1. 6 */ 7#include <stdio.h>8#include <string.h>9 Chara[ -],b[ -];Ten voidDel (intIndexintLen) { One for(intI=0; i<len;i++){ A if(index = = i)Continue;//Subscript is the same as the same element does not compare, into the next loop - if(B[index] = = A[i]) b[index]=-1;//have the same element with a value of-1 - } the } - intMain () { - gets (a); -memcpy (B,a,sizeof(a));//Copy the elements of A to B + intLen=strlen (a);//find the length of a - for(intI=0; i<len;i++){ + Del (I,len); A } at for(intI=0; i<len;i++) {//elements of non-1 in output B - if(b[i]!=-1){ -printf"%c", B[i]); - } - } - return 0; in}
C language · Delete duplicate elements