摘要: 字符串统计 题目分析: 录入字符串,判断数字有多少个,累加保存。 代码: #include<iostream> using namespace std; int main() { char a[100001]; int n; while (cin >> n&&n) { while (n--) { g 阅读全文
posted @ 2020-02-08 01:59 PCDL&TIPO 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 数据的交换输出 题目分析: 找到最小值,然后与第一个换位置 代码: #include<iostream> using namespace std; int main() { int n; int a[101]; while (cin >> n&&n) { int i,t, min = 99999; 阅读全文
posted @ 2020-02-08 01:56 PCDL&TIPO 阅读(163) 评论(0) 推荐(0) 编辑
摘要: 青年歌手大奖赛_评委会打分 题目分析: 判断出最大值和最小值,然后删去,最后将留下的数进行平均 代码: #include <iostream> using namespace std; int main() { int n; while (cin>>n) { int score, sum = 0, 阅读全文
posted @ 2020-02-08 01:50 PCDL&TIPO 阅读(149) 评论(0) 推荐(0) 编辑
摘要: 蟠桃记 题目分析: 很普通的一道函数题,利用所给的条件,进行过程的模拟,构造出一个函数 代码: #include<iostream> using namespace std; int fun(int m) { int sum = 0; if (m == 1) { return 1; } else{ 阅读全文
posted @ 2020-02-08 01:46 PCDL&TIPO 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 素数判定 题目分析: 构造一个判断素数的函数fun,利用fun函数判断区间内的素数。 代码: #include <iostream> #include <math.h> #define fun(n) n*n + n + 41 using namespace std; int prime(int n) 阅读全文
posted @ 2020-02-08 01:42 PCDL&TIPO 阅读(202) 评论(0) 推荐(0) 编辑
摘要: 多项式求和 题目分析: 一道经典的入门算法题,利用for循环以及-1的累乘,进行计算,代码如下 代码: #include<iostream> using namespace std; int main(){ int i, n; int t = 1; int cnt; double sum, num; 阅读全文
posted @ 2020-02-08 01:39 PCDL&TIPO 阅读(179) 评论(0) 推荐(0) 编辑
摘要: 水仙花数 题目分析: 水仙花数也被称为超完全数字不变数(pluperfect digital invariant, PPDI)、自恋数、自幂数、阿姆斯壮数或阿姆斯特朗数(Armstrong number),水仙花数是指一个 3 位数,它的每个位上的数字的 3次幂之和等于它本身(例如:1^3 + 5^ 阅读全文
posted @ 2020-02-08 01:36 PCDL&TIPO 阅读(141) 评论(0) 推荐(0) 编辑