1+2+3+...+n = (1+n)*n/2
//从1循环到n,每次加1 for (int i = 1; i <= n; i ++ ) { sum += i; //累加求和 }
double a; printf("%.7lf", a); //保留7位小数
double pi = acos(-1.0);