题解 | #规律数列求和#
规律数列求和
https://www.nowcoder.com/practice/e05d1c142b3d4898be7183289a00ce5f
#include <cmath> #include <iostream> using namespace std; int main() { long sum = 0; for (int i = 1; i<=10 ; i++) { sum+=pow(10,i)-1; } cout<<sum; return 0; }
规律数列求和
https://www.nowcoder.com/practice/e05d1c142b3d4898be7183289a00ce5f
#include <cmath> #include <iostream> using namespace std; int main() { long sum = 0; for (int i = 1; i<=10 ; i++) { sum+=pow(10,i)-1; } cout<<sum; return 0; }
相关推荐