# Problems in Nankai district (1)

Source: Internet
Author: User

Requirement: scan the str string from left to right, move all the characters on the left of lowercase letter o to the right of the string, and delete the lowercase letter o, scan the str string and perform the preceding operations until all lowercase letters o in str are deleted. The answer is as follows: [cpp] void StrOR (void) {int I, j, k = 0; // defines three variables. I indicates the number of rows, and j indicates the number of columns, k points to the first character int len of each row; // It is used to store the number of characters in each row. char buf [80]; // It is used to store the row data of temporary transformation. char a = 0; // when row data is stored in a temporary array, the row data is cleared with 0 characters (I = 0; I <maxline; I ++) {len = strlen (xx [I]); // obtain the number of characters in each line j = 0; while (j <len) {if (xx [I] [j] = 'O') // determines whether the character is o {xx [I] [j] = 0; // Replace the character o position with zero to make the string copy and connection take effect. When the string connection function and the copy function have zero characters, strcpy (buf, & xx [I] [j + 1]);/* strcpy function: Prototype Declaration: extern char * strcpy (char Dest [], const char * src); function: copy the string starting from the src address and containing the NULL terminator to the address space starting with dest, and copy the string ending mark together. note: The memory areas specified by src and dest cannot overlap and dest must have sufficient space to accommodate src strings. Returns the pointer to dest. */Strcat (buf, xx [I]);/* strcat function: Prototype: extern char * strcat (char * strDest, char * strSrc); function: add the strSrc string to the end of strDest (overwrite '\ 0' at the end of strDest) and add '\ 0'. Note: the memory regions specified by strSrc and strDest cannot overlap and strDest must have enough space to accommodate strSrc strings. Returns the pointer to strDest. www.2cto.com */strset (xx [I], a); // clear the data in xx [I, so that the strcpy (xx [I], buf) error will not occur when obtaining data from the temporary array ); // copy the data in the temporary array to the row array of xx len = len-j; // The Last j characters in the copied data do not contain the character o j = 0; // set j to 0 and re-operate the new data} else {j ++ ;}}}}

Related Keywords:
Related Article

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.