In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how C language encapsulates letter digital strings". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought. Let's study and learn "how C language encapsulates function digital strings".
Encapsulated function: judging leap years and peaceful years
This function determines whether the incoming year is a leap year and a peaceful year, and the result is represented by the return value.
# include / / function declaration int GetYearSate (int year); int main () {int year; printf ("Please enter year:"); scanf ("% d", & year); / / judging leap year and year if (GetYearSate (year)) {printf ("normal year.\ n");} else {printf ("Leap year.\ n");} return 0 Function function: judge the return value of leap year in normal year: 0 indicates leap year 1 indicates normal year * / int GetYearSate (int year) {if ((year%4==0 & & year0 years 0) | | (year%400==0)) {return 0;} return 1;} encapsulates function: string lookup (see strstr)
The first step is to see help: man strstr
# include # include / / declare the function's char * my_strstr (char * src_str,char * find_str); int main () {char src_str [100]; / / "123456789" char find_str [100]; printf ("Please enter string:"); scanf ("% s", src_str); printf ("Please enter the string you are looking for:"); scanf ("% s", find_str) / / strstr () / / finds the specified string and returns the first address of the lookup string in the source string printf ("found string result:% s\ n", strstr (src_str,find_str)); printf ("found string result:% s\ n", my_strstr (src_str,find_str)); return 0 } / / function function: string lookup function / / return value: return the found string address char * my_strstr (char * src_str,char * find_str) {int src_len; int find_len; int iJournal j; src_len=strlen (src_str); find_len=strlen (find_str); for (iS0) ISome0' & * str='0' & & * strcnt_f) {cnt=cnt_f;} data_f+=data*my_pow (0.1Magneto cnt); return data_f;} / / function function: calculate the y power of x / / my_pow (2mai 3); double my_pow (double x pencil int y) {double tmp=1.0; int i; for (iMago match I)
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.