C++ 程序计算表达式值 (1^2 + 2^2 + ... + n^2) / n 日期: 2026-01-25 17:43:15 标签: 常规 #include #include #include #include using namespace std; int n; double ans; int main(){ cin>>n; if(n<=0) ans=0; else{ for(int i=1;i<=n;i++){ ans+=pow(i,2); } ans/=n; } printf('表达式的值=%.4f',ans); return 0; } 原文地址: https://www.cveoy.top/t/topic/njnF 著作权归作者所有。请勿转载和采集! 免费AI点我,无需注册和登录