A classmate to help some of the problems of MM.
Algorithm Description:
First, two strings and a critical value are passed as arguments to the function, such as "Aaaaaaaaaa", "Bbaaababaa", 2, and then in the function, each character of two strings is compared, and when the number of different characters exceeds the specified threshold, the comparison continues. and converts the same character in the first string that is greater than or equal to the critical value to uppercase, for example, depending on the input above, the output is: AAAAAAAAAA. Requirements: can only use If,else, recursion and string processing related functions.
Welcome to all kinds of brick-making.
//code by pnig0s1992//date:2012,3,13 #include <stdio.h> #include <Windows.h> #include <strin g.h> #include <stdlib.h> #define MAXSIZE int superstr (CHAR lpfirst[],char lplast[],int ICHEC
k);
int main (int argc,char * argv[]) {char lpfirst[] = "AAAAAAAAAA";
CHAR lpsecond[] = "Bbaaababaa";
int icheck = 2;
Superstr (Lpfirst,lpsecond,icheck);
printf ("N modified first string:%s", Lpfirst);
System ("pause");
return 0;
The int superstr (char lpfirst[],char lplast[],int icheck) {char Ctempf = *lpfirst;
CHAR Ctempl = *lplast;
int Itempmark;
Static CHAR Csave;
static LPSTR Lptempstr = (LPSTR) HeapAlloc (GetProcessHeap (), heap_zero_memory,20);
static int icount = 0;
int ireturn = 0;
if (Ctempf = = ' [] ' | | ctempl = = ' [] ') {return 0;
int isame = SUPERSTR (++lpfirst,++lplast,icheck);
if (Ctempf = = Ctempl) {ctempf-=32;
Csave = Ctempf;
icount++;
Ireturn = 1;
}else {if (icount<icheck) icount = 0; } if (Icount >=icheck) {if (icount = 1) {Strnset (Lpfirst-1,ctempf,
icount);
icount = 0;
return 0;
}else {if (Isame = = 0) {strnset (lpfirst+1,csave,icount);
icount = 0;
}} return Ireturn; }
This article is from the "About:blank h4cking" blog, please be sure to keep this source http://pnig0s1992.blog.51cto.com/393390/805284