In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces how to realize the function of word assistant in C language, which has a certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article.
The details are as follows
I. topic analysis
1. Add document comments, function comments and statement comments to the original code to make the code style good and easy to read and modify.
2. Perfect the function to memorize the wrong words repeatedly.
3. Add the function of query in Chinese and English to the thesaurus maintenance option.
4. Complete the verification of the correctness of input data, such as: entering non-standard error prompts when selecting menus, exception elimination of input Chinese when adding words, etc.
Two. key algorithm construction
1. Check and prompt the input exception of the item selection of the general menu and the sub-option of maintain function.
2. Add words
III. Program implementation
# include # include # define MAX_CHAR 20 / / maximum number of characters # define MAX_NUM 200 / / structure of struct word// words {char en [Max _ CHAR]; / / English form char [Max _ CHAR]; / / Chinese form} s [Max _ NUM], r [Max _ NUM]; / / word array int num; / / number of dictionary words int rnum = 0; / / enhanced memory number of words int select=1 / / select is the mark of whether or not to quit the system, int dong0, dan0, and racket, c is the number of wrong answers, and d is the number of correct answers / / help void help () {printf ("\ nThis system mainly realizes the function of learning English words. Users can preview, add, delete, change and check the words in the dictionary file. ") ; printf ("\ nChinese-English and English-Chinese tests can also be conducted at the same time. The system also provides the display function of test results.") ;} / / read word information from the file void readfile () {FILE * fp; int iword 0; fp=fopen ("data.txt", "r"); if (! fp) {printf ("\ nfailed to open file data.txt!");} while (fscanf (fp, "% s% s", s [I] .en, s [I] .ch) = 2) {iwords;} num=i; if (0roomi) printf ("\ nFile is empty, please select dictionary maintenance to add an entry!") ; else printf ("\ n"); fclose (fp);} / / write the words void writefile () {FILE * fp;int item0 printf ("data.txt", "w") to the file; if (! fp) {printf ("\ nfailed to open the file data.txt!");} for (ix0Exi0) / / string class strcmp function compares {strcpy (temp, SJ-1] .en) character by character through Ascll code Strcpy (s [j-1] .en, s [j] .en); strcpy (s [j] .en, temp); strcpy (temp, s [j-1] .ch); strcpy (s [j-1] .ch, s [j] .ch); strcpy (s [j] .ch, temp);} / / add word information void add () {int ipurnum numjjparry 1, while (flag) {flag=0;printf ("\ nPlease enter the English form of the word:") Scanf ("% s", s [I] .en); / / strncpy (c, s [I] .en.c _ str (), s [I] .en.length ()); for (axiology a > 8 percent 0) {continue;} else {printf ("input is not pure English, please re-enter"); flag=1;goto f transpose / jump} / / if (Awareness 19) continue;for when not pure English input
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.