NOIP2016 阅读程序写结果
1.
#include <iostream> using namespace std; int main() { int max, min, sum, count = 0; int tmp; cin >> tmp; if (tmp == 0) return 0; max = min = sum = tmp; count++; while (tmp != 0) { cin >> tmp; if (tmp != 0) { sum += tmp; count++; if (tmp > max) max = tmp; if (tmp < min) min = tmp; } } cout << max << "," << min << "," << sum / count << endl; return 0; }
输入: 1 2 3 4 5 6 0 7 输出:_________
发表评论