洛谷C语言学习小记

admin 2026-07-19 04:37:57 网络安全文章 来源:ZONE.CI 全球网 0 阅读模式

文章总结: 这是一篇个人C语言学习笔记,作者在洛谷刷题网站记录了几道入门题目的解题思路与代码实现,包括三连击、小鱼的航程、校门外的树、统计单词数、小书童密码和数字反转等。笔记分享了使用计数数组、取余判断工作日、数组标记法、字符串处理等技巧,并对比了与大佬代码的差异,适合C语言初学者参考。 综合评分: 76 文章分类: 其他


cover_image

洛谷C语言学习小记

胡楚昊 胡楚昊

胡楚昊

2026年7月18日 21:43 河南

在小说阅读器读本章

去阅读

最近暑假闲的没事做,想要温习一下C语言,从ACM大佬那里得知了一个刷题网站洛谷。

搜到一个博客是关于洛谷题解的:洛谷编程题解指南-CSDN博客

因此本着学习的心态,记录一下自己觉得有意思的题目

因为是初学者,这里就光做入门的题目了,待到编程能力提高了一点再做做拔高的。

三连击(P1008)

这道题我刚开始做错的地方是没读懂题干

将1,2,…,9共9个数分成三组,分别组成三个三位数,且使这三个三位数构成1:2:3的比例,试求出所有满足条件的三个三位数。

首先我看到了比例,思路是用a代表那一份,然后用2*a和3*a分别代表另外两个数字

自然想到了只需要表示a即可。刚开始我还嵌套循环表示a,其实没那么复杂,一个从123开始的for循环就可以搞定

然后就是划定一下b和c的范围,不可以超过999.现在只剩下最后一个难关,怎么确保这些数字没有重复而且是1-9组成的

问了kimi,只需要初始化一个count[10]数组即可。写一个循环,配合这个数组用来计数,怎么提取每一位的数字呢,可以只看最后一位然后不断左移,就是%10和/10的循环罢了。然后就是需要保证没有0的存在,没有重复的数字

具体算法可以参考以下代码:

| | | — | | #include<iostream> #include<stdio.h> #pragmawarning(disable:6385)//抑制数组越界警告 using namespace&nbsp;std; intmain() { for&nbsp;(int&nbsp;a =&nbsp;123; a <=&nbsp;987; a++) {&nbsp; int&nbsp;b = a *&nbsp;2; int&nbsp;c = a *&nbsp;3; if&nbsp;(b >&nbsp;999&nbsp;|| c >&nbsp;999)&nbsp;continue; &nbsp; int&nbsp;cnt[10] = {&nbsp;0&nbsp;}; int&nbsp;nums[3] = { a, b, c }; for&nbsp;(int&nbsp;i =&nbsp;0; i <&nbsp;3; i++) { int&nbsp;tmp = nums[i]; while&nbsp;(tmp >&nbsp;0) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cnt[tmp %&nbsp;10]++; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tmp /=&nbsp;10; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; } //计数部分 bool&nbsp;ok =&nbsp;true; if&nbsp;(cnt[0] ==&nbsp;1) ok =&nbsp;false; for&nbsp;(int&nbsp;i =&nbsp;1; i <&nbsp;10; i++) { if&nbsp;(cnt[i] !=&nbsp;1) ok =&nbsp;false; &nbsp; &nbsp; &nbsp; &nbsp;} if&nbsp;(ok) { cout&nbsp;<< a <<&nbsp;" "&nbsp;<< b <<&nbsp;" "&nbsp;<< c <<&nbsp;endl; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; } return0; } |

因为我这里编译器提示越界,实则并没有越界,加了一个警告提示符

这里说明下,洛谷P1980题目思路和这个题目有相同之处,所以这个计数方法可以留意一下。

小鱼的航程(P1424)

题目描述就不写了,就是说这只fish每周六日都会休息,其他时间都是每天前进250米。

这道题之所以记录是因为我觉得我的思路很不错

因为星期几都是固定的,取余可以很好的完成这个任务

所以一个if就可以轻松判断是否是工作日:

| | | — | | #include<iostream> #include<stdio.h> using namespace&nbsp;std; intmain() { int&nbsp;x ; long&nbsp;n; cin&nbsp;>> x >> n; int&nbsp;miles =&nbsp;0; for&nbsp;(int&nbsp;i =&nbsp;0; i < n; i++) { if&nbsp;(!(x %&nbsp;7&nbsp;==&nbsp;6&nbsp;|| x%7==0)) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; miles +=&nbsp;250; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; x++; &nbsp; &nbsp; } cout&nbsp;<< miles; return0; } |

校门外的树(洛谷-P1047)

题目描述:

某校大门外长度为L的马路上有一排树,每两棵相邻的树之间的间隔都是1米。我们可以把马路看成一个数轴,马路的一端在数轴0的位置,另一端在L的位置;数轴上的每个整数点,即0,1,2,……,L,都种有一棵树。

由于马路上有一些区域要用来建地铁。这些区域用它们在数轴上的起始点和终止点表示。已知任一区域的起始点和终止点的坐标都是整数,区域之间可能有重合的部分。现在要把这些区域中的树(包括区域端点处的两棵树)移走。你的任务是计算将这些树都移走后,马路上还有多少棵树。

通过这个题目了解到一个新知识:

当提示这个信息的时候,是因为C/C++ 里写在函数内部直接定义的数组 / 大变量,是放在栈(stack)里的:

  • Windows VS 默认程序栈大小一般只有 1MB(约 1024×1024=1048576 字节)
  • 虽然 10000 个 int (40KB) 没到上限,但 VS 静态检查会提前告警:局部数组太大,不推荐放栈上

所以我们把这个写在main函数外部就不会有问题了

某校大门外长度为 l 的马路上有一排树,每两棵相邻的树之间的间隔都是 1 米。我们可以把马路看成一个数轴,马路的一端在数轴 0 的位置,另一端在 l 的位置;数轴上的每个整数点,即 0,1,2,…,l,都种有一棵树。

由于马路上有一些区域要用来建地铁。这些区域用它们在数轴上的起始点和终止点表示。已知任一区域的起始点和终止点的坐标都是整数,区域之间可能有重合的部分。现在要把这些区域中的树(包括区域端点处的两棵树)移走。你的任务是计算将这些树都移走后,马路上还有多少棵树。

根据题目描述长度为L,因为起点是0,所以数组长度没有弄好,长度是L的话应该是一共有L+1颗树的

下面是我的代码:

| | | — | | #include<iostream> #include<stdio.h> using namespace&nbsp;std; int&nbsp;trees[10000]; intmain() { int&nbsp;l, m,a,b; cin&nbsp;>> l >> m; int&nbsp;r=0; for&nbsp;(int&nbsp;i =&nbsp;0; i <= l; i++) { &nbsp; &nbsp; &nbsp; &nbsp; trees[i] =&nbsp;1; &nbsp; &nbsp; } for&nbsp;(int&nbsp;i =&nbsp;0; i < m; i++) { cin&nbsp;>> a >> b; for&nbsp;(int&nbsp;j = a; j <= b; j++) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; trees[j] =&nbsp;0; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; } for&nbsp;(int&nbsp;i =&nbsp;0; i <= l; i++) { if&nbsp;(trees[i] ==&nbsp;0) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; r++; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; } cout&nbsp;<< l+1-r; return0; } |

统计单词数(洛谷-P1308)

我这里因为暂时不会KMP算法,因此就采取暴力一点的方式统计单词数量了

题目描述:

给定一个单词,请你输出它在给定的文章中出现的次数和第一次出现的位置。注意:匹配单词时,不区分大小写,但要求完全匹配,即给定单词必须与文章

中的某一独立单词在不区分大小写的情况下完全相同(参见样例1 ),如果给定单词仅是文章中某一单词的一部分则不算匹配(参见样例2 )。

第一思路就是首先得利用空格分隔出来单词,形成单词列表后通过数组的形式进行匹配。

第二思路是因为单词必须得保证是大小写忽略,因此我们先转换单词为全是小写吧,这一步可以在单词数组初始化的时候进行。

这里需要格外注意,C语言字符串的结尾是\x00,所以第二步的时候不要忘记加上

这是我的刚开始的想法,后来对答案的时候发现和标准答案还是有很大的差别的。而且对for循环我的理解肯定比不过标准答案。具体来说就是,for循环初始化那一部分可以写上希望在循环开始的时候执行一次的代码,相应的循环变量处理的时候可以写每次循环结束后希望执行的代码。

按照我的思路来说还是比较麻烦,还得单独写一个变量存储单词首字母的出现位置,这个时机我觉得在单词转换的时候就不错,转换单词的时候直接写入首字母的位置到一个和单词数组配套的数组即可

| | | — | | #include<iostream> #include<cstring> using namespace&nbsp;std; char&nbsp;input[10000005]; char&nbsp;a[1005]; char&nbsp;c[500005][105]; &nbsp; &nbsp; int&nbsp;start_pos[500005]; intmain()&nbsp;{ cin&nbsp;>> a; cin.ignore(100000,&nbsp;'\n');//清缓冲区 cin.getline(input,&nbsp;sizeof(input));//防止空格后的内容丢失 int&nbsp;len =&nbsp;strlen(input); int&nbsp;a_len =&nbsp;strlen(a); for&nbsp;(int&nbsp;i =&nbsp;0; i < a_len; i++) a[i] =&nbsp;tolower(a[i]); int&nbsp;word_count =&nbsp;0; int&nbsp;pos =&nbsp;0;//单词内部指针 int&nbsp;word_start =&nbsp;0; for&nbsp;(int&nbsp;i =&nbsp;0; i <= len; i++) { if&nbsp;(input[i] ==&nbsp;' '&nbsp;|| input[i] ==&nbsp;'\0') { //说明到了一个单词的结尾 if&nbsp;(pos >&nbsp;0) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; c[word_count][pos] =&nbsp;'\0'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; start_pos[word_count] = word_start; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; word_count++; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pos =&nbsp;0; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; }&nbsp;else&nbsp;{ //是单词开头 if&nbsp;(pos ==&nbsp;0) word_start = i; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; c[word_count][pos++] =&nbsp;tolower(input[i]); &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; } int&nbsp;index =&nbsp;-1, flags =&nbsp;0; for&nbsp;(int&nbsp;i =&nbsp;0; i < word_count; i++) { if&nbsp;(strcmp(c[i], a) ==&nbsp;0) { if&nbsp;(index ==&nbsp;-1) index = start_pos[i]; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flags++; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; } if&nbsp;(flags)&nbsp;cout&nbsp;<< flags <<&nbsp;" "&nbsp;<< index; elsecout&nbsp;<<&nbsp;"-1"; return0; } |

按照大佬的思路,比较的时候无非是在单词刚开始的时候进行比较,所以我们也没必要非要转换为数组,反而浪费时间。不如直接抓住这时候前一位是一个空格,然后进行逐个比较即可。至于首字母的时机,在比较前直接赋值就行了,正如刚才说的for循环理解就是应用到了这个地方

附上大佬代码:

| | | — | | #include<iostream> #include<cstring> #include<cstdio> using namespace&nbsp;std; intmain() { char&nbsp;confirm[11],article[1000001]; int&nbsp;i,j,total=0,flag=0,work=-1; &nbsp; &nbsp; gets(confirm); &nbsp; &nbsp; gets(article); for(i=0;confirm[i]!='\0';i++)//全部转化为小写字母 if(confirm[i]>'A'&&confirm[i]<'Z') &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; confirm[i]=char(confirm[i]+32); for(i=0;article[i]!='\0';i++)//全部转化为小写字母 if(article[i]>'A'&&article[i]<'Z') &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; article[i]=char(article[i]+32); for(i=0;article[i]!='\0';i++)//统计过程 &nbsp; &nbsp; { if((i==0||article[i-1]==' ')&&(confirm[0]==article[i]))//划分单词 &nbsp; &nbsp; &nbsp; { for(flag=i,j=0;confirm[j]!='\0';j++,i++)//但凡有一个字母不同,终止本轮循环 if(confirm[j]!=article[i]) break; if(strlen(confirm)==j&&(article[i]==' '||article[i]=='\0'))//有相同单词,进行统计 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; total++; if(total==1) &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; work=flag; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp;} if(total>0) &nbsp;&nbsp; cout<<total<<" "<<work<<endl;//存在相同单词,输出个数 else cout<<work<<endl;//不存在相同单词,输出-1 return0; } |

小书童——密码(洛谷-P1914)

实际上这道题就是实现了一次凯撒加密。凯撒加密移位算法在数学里面能用mod 26表示,这也是一样,因此还算稍微简单的算法

| | | — | | #include<iostream> #include<cstring> using namespace&nbsp;std; intmain() { char&nbsp;password[1000000]; int&nbsp;offset; cin&nbsp;>> offset; cin&nbsp;>> password; for&nbsp;(int&nbsp;i =&nbsp;0; i <&nbsp;strlen(password); i++) { &nbsp; &nbsp; &nbsp; &nbsp; password[i] =&nbsp;97&nbsp;+ (password[i] + offset -&nbsp;97) %&nbsp;26; &nbsp; &nbsp; } cout&nbsp;<< password; return0; } |

这道题为社么想要记录是因为和大佬思路不一样,我是想直接寻找到偏移量再加上’a’,大佬思路是想一步到位,通过原来的字母直接加上对应的偏移得到新字母,所以按照后者的做法需要单独写一个判断来校验是否超过了’z’。我感觉我的这个思路还算是比较简洁。做逆向题的时候经常见

数字反转(升级版)(洛谷-P1553)

这道题真的没有一点头绪

询问了chatGPT。他给了一个需要用到一些库函数的做法: 思路是,由于小数这些特殊数字的后面反转之后去除后置0,而整数反转后去除前导0,那我们不如写一个if判断,只要将数字区分开就好办了,如果杂糅在一起不是太好处理。

| | | — | | #include<iostream>// 输入输出 #include<vector>// 动态数组 #include<algorithm>// sort排序 using namespace&nbsp;std; using namespace&nbsp;std; stringrev(string&nbsp;s)&nbsp;{ &nbsp; &nbsp; reverse(s.begin(), s.end()); int&nbsp;i =&nbsp;0; while&nbsp;(s[i] ==&nbsp;'0'&nbsp;&& i < s.size() -&nbsp;1) { &nbsp; &nbsp; &nbsp; &nbsp; i++; &nbsp; &nbsp; } return&nbsp;s.substr(i); } intmain() { string&nbsp;s; cin&nbsp;>> s; if&nbsp;(s.back() ==&nbsp;'%'&nbsp;) { string&nbsp;a = &nbsp;s.substr(0,s.size() -&nbsp;1); cout&nbsp;<< rev(a) <<&nbsp;"%"; &nbsp; &nbsp; }&nbsp;//分数 elseif&nbsp;(s.find('/') !=&nbsp;string::npos) &nbsp; &nbsp; { int&nbsp;p = s.find('/'); string&nbsp;a = s.substr(0, p); string&nbsp;b = s.substr(p +&nbsp;1); cout&nbsp;<< rev(a) <<&nbsp;"/"&nbsp;<< rev(b); &nbsp; &nbsp; } //小数 elseif&nbsp;(s.find('.') !=&nbsp;string::npos) &nbsp; &nbsp; { int&nbsp;p = s.find('.'); string&nbsp;a = s.substr(0, p); string&nbsp;b = s.substr(p +&nbsp;1); &nbsp; &nbsp; &nbsp; &nbsp; a = rev(a); &nbsp; &nbsp; &nbsp; &nbsp; reverse(b.begin(), b.end()); //处理小数末尾0 bool&nbsp;allzero =&nbsp;true; for&nbsp;(char&nbsp;c : b) &nbsp; &nbsp; &nbsp; &nbsp; { if&nbsp;(c !=&nbsp;'0') &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; allzero =&nbsp;false; break; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; } if&nbsp;(allzero) &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; b =&nbsp;"0"; &nbsp; &nbsp; &nbsp; &nbsp; } else &nbsp; &nbsp; &nbsp; &nbsp; { while&nbsp;(b.back() ==&nbsp;'0') &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; b.pop_back(); &nbsp; &nbsp; &nbsp; &nbsp; } cout&nbsp;<< a <<&nbsp;"."&nbsp;<< b; &nbsp; &nbsp; } //整数 else &nbsp; &nbsp; { cout&nbsp;<< rev(s); &nbsp; &nbsp; } return0; } |

大佬的做法又是让我想不到的一次。上面的做法很显然作弊了,用了太多的库函数

这个主要没想到的地方是如何分类,大佬做法简单粗暴:就是单独搞一个flag当作符号位,到时候根据符号位前还是后反转即可。但是不想做就是因为自己没有在玩下一步想,特殊点就是多了一个符号,根据符号在哪里进行进一步思考就可以。 由此引发了我进一步的思考,高中的时候还在想,如何将一道题写出来,就是检查题考的知识,如何将题目映射到知识上,有的题都是根据某一类题目演化,做的多了就会了。因此当时还尝试过写母题。C语言\CTF不都是如此,都有基础知识的要求,都有一类题目特别经典。对于经典的题目,应该思考思考他怎么结合、结合了哪些知识点,然后熟能生巧

对于这种反转的题,无非就是倒着写一个for循环。复杂的地方在于需要写几个条件分支而已。

| | | — | | #include<iostream> #include<cstring> using namespace&nbsp;std; intmain() { char&nbsp;num[100000] = {0}; char&nbsp;result[100000] = {0}; cin&nbsp;>> num; int&nbsp;len =&nbsp;strlen(num); int&nbsp;index = len; char&nbsp;flag =&nbsp;0; int&nbsp;i; // 找特殊符号位置 for(i =&nbsp;0; i < len; i++) &nbsp; &nbsp; { if(num[i]=='.'&nbsp;|| num[i]=='/'&nbsp;|| num[i]=='%') &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flag = num[i]; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; index = i; break; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; } // ===================== // 整数 // ===================== if(index == len) &nbsp; &nbsp; { // 整体反转 for(i=0;i<len;i++) &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result[i]=num[len-i-1]; &nbsp; &nbsp; &nbsp; &nbsp; } // 去前导0 int&nbsp;start=0; while(start<len-1&nbsp;&& result[start]=='0') &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; start++; &nbsp; &nbsp; &nbsp; &nbsp; } for(i=start;i<len;i++) &nbsp; &nbsp; &nbsp; &nbsp; { cout<<result[i]; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; } // ===================== // 小数 // ===================== elseif(flag=='.') &nbsp; &nbsp; { // 整数部分反转 for(i=0;i<index;i++) &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result[i]=num[index-i-1]; &nbsp; &nbsp; &nbsp; &nbsp; } // 小数点 &nbsp; &nbsp; &nbsp; &nbsp; result[index]='.'; // 小数部分反转 for(i=index+1;i<len;i++) &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result[i]=num[len-i+index]; &nbsp; &nbsp; &nbsp; &nbsp; } // 去整数部分前导0 int&nbsp;start=0; while(start<index-1&nbsp;&& result[start]=='0') &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; start++; &nbsp; &nbsp; &nbsp; &nbsp; } // 去小数部分末尾0 int&nbsp;end=len-1; while(end>index+1&nbsp;&& result[end]=='0') &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end--; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; result[end+1]='\0'; // 输出 for(i=start;result[i]!='\0';i++) &nbsp; &nbsp; &nbsp; &nbsp; { cout<<result[i]; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; } // ===================== // 分数 // ===================== elseif(flag=='/') &nbsp; &nbsp; { // 分子反转 for(i=0;i<index;i++) &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result[i]=num[index-i-1]; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; result[index]='/'; // 分母反转 for(i=index+1;i<len;i++) &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result[i]=num[len-i+index]; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; result[len]='\0'; // 分子去前导0 int&nbsp;start=0; while(start<index-1&nbsp;&& result[start]=='0') &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; start++; &nbsp; &nbsp; &nbsp; &nbsp; } // 输出分子 for(i=start;i<=index;i++) &nbsp; &nbsp; &nbsp; &nbsp; { cout<<result[i]; &nbsp; &nbsp; &nbsp; &nbsp; } // 分母去前导0 &nbsp; &nbsp; &nbsp; &nbsp; start=index+1; while(start<len-1&nbsp;&& result[start]=='0') &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; start++; &nbsp; &nbsp; &nbsp; &nbsp; } // 输出分母 for(i=start;i<len;i++) &nbsp; &nbsp; &nbsp; &nbsp; { cout<<result[i]; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; } // ===================== // 百分数 // ===================== elseif(flag=='%') &nbsp; &nbsp; { // 数字部分反转 for(i=0;i<index;i++) &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result[i]=num[index-i-1]; &nbsp; &nbsp; &nbsp; &nbsp; } // 去数字部分前导0 int&nbsp;start=0; while(start<index-1&nbsp;&& result[start]=='0') &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; start++; &nbsp; &nbsp; &nbsp; &nbsp; } // 输出数字 for(i=start;i<index;i++) &nbsp; &nbsp; &nbsp; &nbsp; { cout<<result[i]; &nbsp; &nbsp; &nbsp; &nbsp; } // 输出百分号 cout<<'%'; &nbsp; &nbsp; } return0; } |

用一句毛主席的诗说就是自信人生二百年,会当水击三千里。

回文质数(P1217)

这里打算用递归实现这个算法,听说递归很耗时间,这里只是作为锻炼编程能力。原代码是通过循环构造回文数并且判断是否都是质数来实现的

| | | — | | #include<iostream> using namespace&nbsp;std; // 辅助函数:获取数字位数 intgetLen(int&nbsp;n) { if&nbsp;(n <&nbsp;10)&nbsp;return1; return1&nbsp;+ getLen(n /&nbsp;10); } // 递归判断回文数 boolisPalindrome(int&nbsp;num) { if&nbsp;(num <&nbsp;0)&nbsp;returnfalse; if&nbsp;(num <&nbsp;10)&nbsp;returntrue; int&nbsp;len = getLen(num); int&nbsp;high = num / (int)pow(10, len -&nbsp;1); int&nbsp;low = num %&nbsp;10; if&nbsp;(high != low) returnfalse; int&nbsp;next = (num % (int)pow(10, len -&nbsp;1)) /&nbsp;10; return&nbsp;isPalindrome(next); } intmain() { int&nbsp;x; cin&nbsp;>> x; if&nbsp;(isPalindrome(x)) cout&nbsp;<<&nbsp;"是回文数"; else cout&nbsp;<<&nbsp;"不是回文数"; return0; } |

我这个代码没有考虑是素数的情况

数的计算(P2001)

这个题直接让我失去了思路,根本找不到相关的表达式了

最后看了ChatGPT的回答,了解到估计是找到一个递推关系

假设f(n)表示以n开头的数列构造后满足条件的个数,比如f(6),第二个数字可以是3,【6,3】本身是一个数列,排除这种情况,那么f(6)可以拆成1+f(3)。6后面同样可以跟1,2,3.因此这就是一个递归函数,f(6)到f(3)就是n/2的改变而已,据此写出递归函数

只要用递归就会提示[TLE]也就是时间超出限制。所以我们需要加上递归的记忆,啥意思呢?只需要加一个数组,减少大量重复计算即可,就像下面这样。

| | | — | | #include<iostream> using namespace&nbsp;std; longlong&nbsp;dp[100005]; longlongsolve(int&nbsp;i) { if(dp[i]) return&nbsp;dp[i]; longlong&nbsp;a=1; for(int&nbsp;j=1;j<=i/2;j++) &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; a+=solve(j); &nbsp; &nbsp; } &nbsp; &nbsp; dp[i]=a; return&nbsp;a; } intmain() { int&nbsp;n; cin>>n; cout<<solve(n); return0; } |

问了大佬,说这种前一步操作影响下一步的题就是动态规划或递归的思路。

火柴棒等式(洛谷-P1149)

这道题真的是没有一点点思路

问了chatGPT。我们其实抓住关键一点:已知条件是火柴棒的每个数字的条数,分析一个等式成立的条件,肯定是火柴棒数量能对上。我们编程里面需要一个条件,这就是一个筛选条件,然后枚举即可。

数字分别需要这些根火柴棒:number[10]={6,2,5,5,4,5,6,3,7,6}

我们还需要4根拼接成+和=符号。据此写出脚本筛选即可。

而且题目这句话可以视为一个简单的提示:如果 A=B,则 A+B=C 与 B+A=C 视为不同的等式(A,B,C≥0)就是让我们大胆枚举

| | | — | | #include<iostream> using namespace&nbsp;std; intsum(int&nbsp;i)&nbsp;{ int&nbsp;r; int&nbsp;number[10] = {&nbsp;6,2,5,5,4,5,6,3,7,6&nbsp;}; if&nbsp;(i /&nbsp;10&nbsp;>&nbsp;0) { &nbsp; &nbsp; &nbsp; &nbsp; r = number[i %&nbsp;10] + sum(i /&nbsp;10); &nbsp; &nbsp; } else&nbsp;{ &nbsp; &nbsp; &nbsp; &nbsp; r = number[i %&nbsp;10]; &nbsp; &nbsp; } return&nbsp;r; } intmain() { int&nbsp;n, r=0; cin&nbsp;>> n; for&nbsp;(int&nbsp;i =&nbsp;0; i <&nbsp;999; i++) { for&nbsp;(int&nbsp;j =&nbsp;0; j <&nbsp;999; j++) { if&nbsp;(sum(i) + sum(j) + sum(i + j)+4&nbsp;== n) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; r++; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; } cout&nbsp;<< r; } |

数字反转(洛谷-P1307)

这里主要记载另一种数字反转的思路: 比如一个三位数abc,反转的时候本质上就是数字的位权发生了变化。比如反转之后c成为了原来的100倍。怎么用代码实现呢?从0开始,每一次乘以10实现位权增大,让c最开始乘10,b次之,a不乘,即实现位权的变化。这样说大家可能难以理解,配合下面实例很好理解:

| | | — | | while(n!=0) &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; sum=sum*10+(n%10); &nbsp; &nbsp; &nbsp; &nbsp; n/=10; &nbsp; &nbsp; } |

P2089 烤鸡

刚开始没想到枚举的思路,小看电脑算力了

看有人用搜索算法,我还没学到,只能说是留着以后填坑巴

| | | — | | #include<iostream> using namespace&nbsp;std; intmain() { int&nbsp;n, sum =&nbsp;0; int&nbsp;ing1, ing2, ing3, ing4, ing5, ing6, ing7, ing8, ing9, ing10; cin&nbsp;>> n; /*每种材料依次遍历,当相加符合美味度时,方案数+1*/ for&nbsp;(ing1 =&nbsp;1; ing1 <=&nbsp;3; ing1++) for&nbsp;(ing2 =&nbsp;1; ing2 <=&nbsp;3; ing2++) for&nbsp;(ing3 =&nbsp;1; ing3 <=&nbsp;3; ing3++) for&nbsp;(ing4 =&nbsp;1; ing4 <=&nbsp;3; ing4++) for&nbsp;(ing5 =&nbsp;1; ing5 <=&nbsp;3; ing5++) for&nbsp;(ing6 =&nbsp;1; ing6 <=&nbsp;3; ing6++) for&nbsp;(ing7 =&nbsp;1; ing7 <=&nbsp;3; ing7++) for&nbsp;(ing8 =&nbsp;1; ing8 <=&nbsp;3; ing8++) for&nbsp;(ing9 =&nbsp;1; ing9 <=&nbsp;3; ing9++) for&nbsp;(ing10 =&nbsp;1; ing10 <=&nbsp;3; ing10++) if&nbsp;(ing1 + ing2 + ing3 + ing4 + ing5 + ing6 + ing7 + ing8 + ing9 + ing10 == n) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sum++; cout&nbsp;<< sum <<&nbsp;endl;//输出方案数 /*每种材料依次遍历,当相加符合美味度时,输出当前方案*/ for&nbsp;(ing1 =&nbsp;1; ing1 <=&nbsp;3; ing1++) for&nbsp;(ing2 =&nbsp;1; ing2 <=&nbsp;3; ing2++) for&nbsp;(ing3 =&nbsp;1; ing3 <=&nbsp;3; ing3++) for&nbsp;(ing4 =&nbsp;1; ing4 <=&nbsp;3; ing4++) for&nbsp;(ing5 =&nbsp;1; ing5 <=&nbsp;3; ing5++) for&nbsp;(ing6 =&nbsp;1; ing6 <=&nbsp;3; ing6++) for&nbsp;(ing7 =&nbsp;1; ing7 <=&nbsp;3; ing7++) for&nbsp;(ing8 =&nbsp;1; ing8 <=&nbsp;3; ing8++) for&nbsp;(ing9 =&nbsp;1; ing9 <=&nbsp;3; ing9++) for&nbsp;(ing10 =&nbsp;1; ing10 <=&nbsp;3; ing10++) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { if&nbsp;(ing1 + ing2 + ing3 + ing4 + ing5 + ing6 + ing7 + ing8 + ing9 + ing10 == n) { cout&nbsp;<< ing1 <<&nbsp;" "; cout&nbsp;<< ing2 <<&nbsp;" "; cout&nbsp;<< ing3 <<&nbsp;" "; cout&nbsp;<< ing4 <<&nbsp;" "; cout&nbsp;<< ing5 <<&nbsp;" "; cout&nbsp;<< ing6 <<&nbsp;" "; cout&nbsp;<< ing7 <<&nbsp;" "; cout&nbsp;<< ing8 <<&nbsp;" "; cout&nbsp;<< ing9 <<&nbsp;" "; cout&nbsp;<< ing10 <<&nbsp;" "; cout&nbsp;<<&nbsp;endl; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } return0; } |

计算器的改良(洛谷-P1022)

通过这道题认识一种编程思想: 人脑是可以模拟很多情况的,就跟这道题一样,是需要编写程序算方程。但是电脑又不会,他分不清现在处于那种情况,因此我们需要维护几个状态变量。原来我的想法是:写的大量if,但是这样自己就绕了进去。实际的做法应该是:保存几个状态变量即可。这也跟计组里面的计算机状态有异曲同工之妙。

以后写代码时,如果发现:

| | | — | | if(...) else if(...) else if(...) else if(...) |

越来越长,而且每个条件都在考虑“之前发生了什么”。

通常说明:

缺少一个状态变量。

应该把:

| | | — | | 之前发生了什么 |

保存下来。

这是我废了老大劲写的第一版没有AC:

| | | — | | #include<iostream> #include<ctype.h> #include<cstring> using namespace&nbsp;std; intmain() { int&nbsp;num =&nbsp;0, alpha =&nbsp;0, c=0; int&nbsp;work =&nbsp;1;//判断是等号左边还是右边 double&nbsp;r; char&nbsp;x; int&nbsp;flag =&nbsp;1; char&nbsp;a[100]; cin&nbsp;>> a; for&nbsp;(int&nbsp;i =&nbsp;0; i <&nbsp;strlen(a); i++) { if&nbsp;(isdigit(a[i])) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; num = num *&nbsp;10&nbsp;+ (a[i] -&nbsp;'0'); &nbsp; &nbsp; &nbsp; &nbsp; } elseif&nbsp;(isalpha(a[i])) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x = a[i]; if&nbsp;(num ==&nbsp;0) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; num =&nbsp;1; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; alpha += work * flag * num; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; num =&nbsp;0; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flag =&nbsp;1; &nbsp; &nbsp; &nbsp; &nbsp; } elseif&nbsp;(a[i] ==&nbsp;'=') { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; c += flag * work * num; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; work =&nbsp;-1; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flag =&nbsp;1; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; num =&nbsp;0; &nbsp; &nbsp; &nbsp; &nbsp; } else&nbsp;{ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; c += work * flag * num; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; num =&nbsp;0; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flag =&nbsp;1; if&nbsp;(a[i] ==&nbsp;'-') { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flag =&nbsp;-1; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; } &nbsp; &nbsp; c += num * flag * work; &nbsp; &nbsp; r = -c / (double)alpha; cout&nbsp;<< x <<&nbsp;"="; printf("%.3f", r); return0; } |

主要在第五个测试点出问题了“

最后经过很多测试数据测试发现问题在这里:

| | | — | | 0x+1+x=0 x=-0.500 |

我代码没有考虑x前面系数本身为0.因此需要新的状态变量存储字母前面有没有其他的数字。

而且需要注意-0和+0评判的系统会不认。所以需要特殊处理:

| | | — | | #include<iostream> #include<ctype.h> #include<cstring> using namespace&nbsp;std; intmain() { int&nbsp;num =&nbsp;0, alpha =&nbsp;0, c =&nbsp;0; bool&nbsp;hasNum =&nbsp;false; int&nbsp;work =&nbsp;1;//判断是等号左边还是右边 double&nbsp;r; char&nbsp;x; int&nbsp;flag =&nbsp;1; char&nbsp;a[100]; cin&nbsp;>> a; for&nbsp;(int&nbsp;i =&nbsp;0; i <&nbsp;strlen(a); i++) { if&nbsp;(isdigit(a[i])) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; num = num *&nbsp;10&nbsp;+ (a[i] -&nbsp;'0'); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hasNum =&nbsp;true; &nbsp; &nbsp; &nbsp; &nbsp; } elseif&nbsp;(isalpha(a[i])) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x = a[i]; if&nbsp;(hasNum) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; alpha += work * flag * num; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } else&nbsp;{ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; alpha += work * flag; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; num =&nbsp;0; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flag =&nbsp;1; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hasNum =&nbsp;false; &nbsp; &nbsp; &nbsp; &nbsp; } elseif&nbsp;(a[i] ==&nbsp;'=') { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; c += flag * work * num; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; work =&nbsp;-1; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flag =&nbsp;1; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; num =&nbsp;0; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hasNum =&nbsp;false; &nbsp; &nbsp; &nbsp; &nbsp; } else&nbsp;{ &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; c += work * flag * num; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; num =&nbsp;0; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hasNum =&nbsp;false; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flag =&nbsp;1; if&nbsp;(a[i] ==&nbsp;'-') { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; flag =&nbsp;-1; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; } &nbsp; &nbsp; c += num * flag * work; &nbsp; &nbsp; r = -c / (double)alpha; if&nbsp;(!r) { cout&nbsp;<< x <<&nbsp;"="; printf("0.000"); &nbsp; &nbsp; } else&nbsp;{ cout&nbsp;<< x <<&nbsp;"="; printf("%.3f", r); &nbsp; &nbsp; } return0; } |

P1036 [NOIP 2002 普及组] 选数

看大佬的博客是用到了深度优先算法,这里不太会这个算法,想想有没有别的思路

但是如果用我的这个思路,素数选择就必须用数论知识进行缩短用埃式筛,这样才能实现不TLE

具体思路是:每个数字只有俩状态,选到或者没选到。因此可以用二进制来表示每个数字

比如,1234随机选1个,是不是可以刚好用0001,0010,0100,1000来表示

这里让我搞不清的就是怎么确定1的数量。后来还是想到了状态机的思路。那就是只需要有1的时候让计数器变量+1即可。

有思路了,先实现选数字,素数的筛选一会再说。

| | | — | | intmain() { int&nbsp;n, k,r=0; int&nbsp;a[20]; cin&nbsp;>> n; cin&nbsp;>> k; int&nbsp;cnk=0,sum=0; &nbsp; &nbsp; init(); for&nbsp;(int&nbsp;i =&nbsp;0; i < n; i++) { cin&nbsp;>> a[i]; &nbsp; &nbsp; } for&nbsp;(int&nbsp;i =&nbsp;0; i < (1&nbsp;<< n); i++) { &nbsp; &nbsp; &nbsp; &nbsp; sum =&nbsp;0; &nbsp; &nbsp; &nbsp; &nbsp; cnk =&nbsp;0; for&nbsp;(int&nbsp;j =&nbsp;0; j < n; j++) { if&nbsp;((i & (1&nbsp;<< j)) >&nbsp;0) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cnk++; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; sum += a[j]; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; } if&nbsp;(cnk == k&&prime[sum]) { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; r++; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; } cout&nbsp;<< r; return0; } |

再来看看素数筛选:要找出 2~n 之间所有质数

  1. 先默认全部数字都是质数;
  2. 从最小质数 2 开始,把它所有倍数全部标记为非质数
  3. 找到下一个没被标记的数,它就是新质数,再标记它所有倍数;
  4. 循环直到遍历到 根号n,剩余未标记的数全部是质数。

| | | — | | bool&nbsp;prime[100000005]; voidinit() { //先全部认为是质数 for&nbsp;(int&nbsp;i =&nbsp;2; i <=&nbsp;100000000; i++) &nbsp; &nbsp; &nbsp; &nbsp; prime[i] =&nbsp;true; //筛质数 for&nbsp;(int&nbsp;i =&nbsp;2; i * i <=&nbsp;100000000; i++) &nbsp; &nbsp; { if&nbsp;(prime[i]) &nbsp; &nbsp; &nbsp; &nbsp; { for&nbsp;(int&nbsp;j = i * i; j <=&nbsp;100000000; j += i) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; prime[j] =&nbsp;false; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; &nbsp; } } |

这里需要注意int prime[100000005];占用空间小,int prime[100000005] = { 1 };占用空间很大。后者可能会导致编译错误

为了进一步缩减空间,int也应该换成bool表示。


免责声明:

本文所载程序、技术方法仅面向合法合规的安全研究与教学场景,旨在提升网络安全防护能力,具有明确的技术研究属性。

任何单位或个人未经授权,将本文内容用于攻击、破坏等非法用途的,由此引发的全部法律责任、民事赔偿及连带责任,均由行为人独立承担,本站不承担任何连带责任。

本站内容均为技术交流与知识分享目的发布,若存在版权侵权或其他异议,请通过邮件联系处理,具体联系方式可点击页面上方的联系我

本文转载自:胡楚昊 胡楚昊 胡楚昊《洛谷C语言学习小记》

洛谷C语言学习小记 网络安全文章

洛谷C语言学习小记

文章总结: 这是一篇个人C语言学习笔记,作者在洛谷刷题网站记录了几道入门题目的解题思路与代码实现,包括三连击、小鱼的航程、校门外的树、统计单词数、小书童密码和数
评论:0   参与:  0