请问各位大佬们,为什么就四十分啊
查看原帖
请问各位大佬们,为什么就四十分啊
1504215
zlh202483023楼主2024/11/21 16:13
#include<iostream>
#include<iomanip>
using namespace std;
int main() {
	int n, k, sum, num, count1, count2;
	cin >> n;
	cin >> k;
	sum = 0;
	num = 0;
	count1 = 0;
	count2 = 0;
	for (int i = 1; i <= n; i++) {
		if (i % k == 0) {
			sum = sum + i;
			count1 ++;
		}
		else if (i % k != 0) {
			num = num + i;
			count2 ++;
		}
	}
	cout << fixed << setprecision(1) << double(sum / count1) << " " << fixed << setprecision(1) << double( num / count2 );
	return 0;
}
2024/11/21 16:13
加载中...