CSP201903-1 小中大
Posted antonliu
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CSP201903-1 小中大相关的知识,希望对你有一定的参考价值。
#include <iostream> #include <cstdio> using namespace std; typedef long long ll; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; int minn, maxx; if (n % 2) { int mid; for (int i = 1; i <= n; i++) { int x; cin >> x; if (i == 1) minn = x; if (i == n) maxx = x; if (i == n / 2 + 1) mid = x; } if (minn > maxx) swap(minn, maxx); cout << maxx << ‘ ‘ << mid << ‘ ‘ << minn << endl; } else { int mid = 0; for (int i = 1; i <= n; i++) { int x; cin >> x; if (i == 1) minn = x; if (i == n) maxx = x; if (i == n / 2 || i == n / 2 + 1) mid += x; } if (minn > maxx) swap(minn, maxx); if (mid % 2 == 0) { mid /= 2; cout << maxx << ‘ ‘ << mid << ‘ ‘ << minn << endl; } else { double midd = mid / 2.0; printf("%d %.1lf %d ", maxx, midd, minn); } } return 0; }
以上是关于CSP201903-1 小中大的主要内容,如果未能解决你的问题,请参考以下文章