标签:i+1 技术 image div 找规律 col space ble pre
找规律的题目。
分析:
因为(n-i)*(i+1) *t可能会超出int范围导致最后两个,所以必须写成 t*(n-i)*(i+1)。
#include<iostream> using namespace std; int main() { int n; double t,sum = 0; cin>>n; for(int i = 0; i < n; ++i) { scanf("%lf",&t); sum += t*(n-i)*(i+1); } printf("%.2f",sum); return 0; }
标签:i+1 技术 image div 找规律 col space ble pre
原文地址:https://www.cnblogs.com/keep23456/p/12334740.html