标签:str char res iostream color main pac ios sum
1 #include <iostream> 2 using namespace std; 3 4 double sum(int args) 5 { 6 double result = 0; 7 for (int i = 0;i < args;i ++) 8 { 9 double part = 1; 10 for (int j = 0;j < i + 1;j ++) 11 { 12 part = part * (j + 1); 13 } 14 result = result + part; 15 } 16 return result; 17 } 18 19 double sum(int args) 20 { 21 double result = 0; 22 double part = 1; 23 for (int i = 1;i <= args;i ++) 24 { 25 part = part * i; 26 result = result + part; 27 } 28 return result; 29 } 30 31 32 int main(int argc, char *argv[]) 33 { 34 return 0; 35 }
求sum = 1!+ 2!+ 3!+...+ n!两种不同的算法
标签:str char res iostream color main pac ios sum
原文地址:https://www.cnblogs.com/royaladd/p/9557534.html