6 条题解
-
5
都怪这个小星上课不好好听讲,让我们来做这道题,还好这题不难,我一个刚学到Level4的都会~只要先判断这个数列是等差数列还是等比数列,再根据情况求出后三个数,最后打印出来就行了O(∩_∩)O
已AC,请放心食用
#include <iostream> using namespace std; int main() { double a, b, c, d, e, f; cin >> a >> b >> c; if (b / a == c / b) { d = c * (c / b); e = d * (c / b); f = e * (c / b); } else if (b - a == c - b) { d = c + (c - b); e = d + (c - b); f = e + (c - b); } cout << d << " " << e << " " << f; return 0; }
养成好习惯,看后点个赞( •̀ ω •́ )✧!
-
1
#include <iostream> using namespace std; int main() { double a, b, c;//设置为double是为了方便除法,如果是int的话除出来都是整数 cin >> a >> b >> c; int num; if (c - b == b - a && c / b != b / a)//等差数列 { num = c - b; cout << c + num << " " << c + 2 * num << " " << c + 3 * num; } if (c - b != b - a && c / b == b / a)//等比数列 { num = c / b; cout << c * num << " " << c * num * num << " " << c * num * num * num; } if (a == b && b == c)//常数列,既是等差数列又是等比数列 { cout << a << " " << a << " " << a; } return 0; }
-
-1
#include <bits/stdc++.h> using namespace std; int main() { int a, b, c; cin >> a >> b >> c; if (b - a == c - b) { int d = c + (b - a); for (int i = 1; i <= 3; i++) { cout << d << " "; d += b - a; } } if (b / a == c / b) { int d = c * (b / a); for (int i = 1; i <= 3; i++) { cout << d << " "; d *= b / a; } } return 0; }
-
-1
号没了
#include <iostream> using namespace std; int main() { double a1,a2,a3; cin >> a1 >> a2 >> a3; if(a2/a1==a3/a2) { cout << a3*(a3/a2) << " " << a3*(a3/a2)*(a3/a2) << " " << a3*(a3/a2)*(a3/a2)*(a3/a2); } else { cout << a3+(a3-a2) << " " << a3+(a3-a2)+(a3-a2) << " " << a3+(a3-a2)+(a3-a2)+(a3-a2); } }
- 1
信息
- ID
- 52
- 时间
- 1000ms
- 内存
- 16MiB
- 难度
- 1
- 标签
- 递交数
- 179
- 已通过
- 118
- 上传者