In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
In this issue, the editor will bring you about how to find the intersection of two strings in c language. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.
Finding the intersection of two strings seems simple, but there are a lot of details to consider.
My train of thought:
1. Simplify the two strings and reduce the repeated letters to one.
two。 Concatenate two strings and find out the characters that repeat twice with the help of a loop.
When you have an idea, start writing code.
1. Main () function
Train of thought:
1. Define two arrays tt [M], pp [M] that store strings
two。 Define the pointer * p to receive the return value of fun2 () and output intersection
3. Enter two strings (note the out-of-bounds problem here)
4. Call function
5. Output intersection
# include # include / / use strcat (), strlen () function # define M 50 void fun1 (char tt []); / / remove the same letters from the string char * fun2 (char tt []); / / find the duplicate (subset) int main () {char tt [M], pp [M]; / / define two arrays to store the string char * p / / accept the address returned by fun2 () and output the intersection string int i; gets (tt); / / abcdef123abc12 gets (pp); / / acef123ace124 fun1 (tt); / / call the function fun1 (pp) / / printf ("% s\ n", tt); / / for inspection use / / printf ("% s\ n", pp); strcat (tt,pp); / / printf ("% s\ n", tt); p=fun2 (tt); / / call function for (iDeplox * (pamphi)! ='\ 0' ) {printf ("% c", * (pairi)); / / acef123} return 0;} II. Fun1 () function
The function of fun1 () is to keep only one repeated character in the string.
Train of thought:
1. First of all, replace the repeated characters with''(here is a space).
two。 Remove''(space) after moving string array elements
Void fun1 (char tt []) / / erase the repetitive characters {int iJournal j; char ch; for
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.