摘要: 该题可以运用while循环直到剩余的空瓶不够换一个新的墨汁,但注意,题目中说了如果差了一个空瓶也是可以再换一个的 点击查看代码 #include<stdio.h> #include<string.h> #include<math.h> int main() { int n, m, i, j, k=0 阅读全文
posted @ 2022-11-09 16:55 美羊羊给沸羊羊搬砖 阅读(84) 评论(0) 推荐(0)
摘要: 这道题如果用普通的冒泡排序,插入排序,选择排序基本上都会时间超限,那不如用c++的sort,方便又快捷,既然都用了c++的,那么他的string定义字符串我们也可以学学 点击查看代码 #include <stdio.h> #include<string.h> #include<algorithm> 阅读全文
posted @ 2022-11-09 16:21 美羊羊给沸羊羊搬砖 阅读(142) 评论(0) 推荐(0)
摘要: 该题与前面的删除前导一样,之前我们是找到第一个不是的字符,那么现在一样的,我们可以从后往前找,找到第一个不是的字符将其前面的删除(不输出) 点击查看代码 #include<stdio.h> #include<string.h> #include<math.h> int main() { char a 阅读全文
posted @ 2022-11-09 16:05 美羊羊给沸羊羊搬砖 阅读(88) 评论(0) 推荐(0)
摘要: 这题完数很简单的,就当练练手。 完数优化的话只用从2查找到n/2+1就行(简单优化); 自定义函数比较方便理解; 点击查看代码 #include <stdio.h> int ws(int x) { int sum=0; for(int i=1;i<x;i++) { if(x%i==0) sum+=i 阅读全文
posted @ 2022-11-09 15:53 美羊羊给沸羊羊搬砖 阅读(85) 评论(0) 推荐(0)