摘要: 问题描述: 输入格式: 输入在一行中给出 10 个非负整数,顺序表示我们拥有数字 0、数字 1、……数字 9 的个数。整数间用一个空格分隔。10 个数字的总个数不超过 50,且至少拥有 1 个非 0 的数字。 输出格式: 在一行中输出能够组成的最小的数。 输入样例: 2 2 0 0 0 3 0 0 阅读全文
posted @ 2020-05-29 22:13 学啥都会 阅读(152) 评论(0) 推荐(0) 编辑
摘要: 问题: 输入格式: 输入在一行中依次给出 3 个整数 A、B 和 D。 输出格式: 输出 A+B 的 D 进制数。 输入样例: 123 456 8 输出样例: 1103 总结: 考虑sum==0的情况 代码: #include <iostream>#include <cstring>#include 阅读全文
posted @ 2020-05-29 22:12 学啥都会 阅读(102) 评论(0) 推荐(0) 编辑
摘要: 问题: 给定一个 k 位整数 N=d​k−1​​10​k−1​​+⋯+d​1​​10​1​​+d​0​​ (0≤d​i​​≤9, i=0,⋯,k−1, d​k−1​​>0),请编写程序统计每种不同的个位数字出现的次数。例如:给定 N=100311,则有 2 个 0,3 个 1,和 1 个 3。 输入 阅读全文
posted @ 2020-05-29 20:50 学啥都会 阅读(171) 评论(0) 推荐(0) 编辑
摘要: 问题描述: 总结: 忘记break;一直无法找见错误; 代码: #include <iostream>#include <cstring>#include <algorithm>#include <cstdio>#include <algorithm>//#include <sstream>//#i 阅读全文
posted @ 2020-05-29 20:32 学啥都会 阅读(99) 评论(0) 推荐(0) 编辑
摘要: 分析: (1) 程序一直有错,半天才发现是自己的命名有问题;谨慎命名; (2) 切记退出循环 (3)学会调试 #include <iostream>#include <cstring>#include <vector>#include <cstdio>#include <cmath>using na 阅读全文
posted @ 2020-05-25 14:35 学啥都会 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 题目: 分析: 倒序输出字符串 输入一行getline(cin, s); stringstream 用法详解 stream<<t ; //向流中传值 stream>>result; //向result中写入值 代码: #include <iostream>#include <cstring>#inc 阅读全文
posted @ 2020-05-23 16:46 学啥都会 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 题目: 分析:(1)不能新建数组不代表不可以扩展数组长度,多出来的空间相当于新建了一个数组。 (2)考虑数字之间关系 ,在输入时做处理** 类似于时钟, (1+2)%6=3 ............(5+2)%6=1, (6+2)%6=2 代码: #include <iostream>#includ 阅读全文
posted @ 2020-05-23 16:22 学啥都会 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 分析: 素数是在大于1的自然数中,除了1和它本身以外不再有其他因数。 2是素数,因为2只能被1和它自己本身整除。 sqrt 函数在<cmath> 中 求素数代码 会背 bool isPrime(int n){ if(n==2||n==3) return true; // key for(int i= 阅读全文
posted @ 2020-05-23 16:00 学啥都会 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 分析: 注意输出空格形式,将容器中其他值设置为0来找出关键字,直接用sort函数排序 #include <iostream>#include <cstring>#include <vector>#include <algorithm>using namespace std;int main(){bo 阅读全文
posted @ 2020-05-23 15:12 学啥都会 阅读(179) 评论(0) 推荐(0) 编辑
摘要: 分析: 使用字符串拼接 #include <iostream>#include <cstring> using namespace std;int main(){ int score; string tem1,tem2, stuma , stumi; int max=-1 , min=10000;i 阅读全文
posted @ 2020-05-22 18:19 学啥都会 阅读(218) 评论(0) 推荐(0) 编辑