标签:std 阶乘 ++ 循环 log clu i++ printf logs
双循环:
1 #include<stdio.h> 2 int main() 3 { 4 int jiech,i,j; 5 long int S=0; 6 for(i=1;i<=10;i++) 7 { 8 j=i; 9 jiech=1; 10 while(j!=0) 11 { 12 jiech*=j; 13 j--; 14 } 15 S+=jiech; 16 } 17 printf("%ld\n",S); 18 return 0; 19 }
单循环:
1 #include<stdio.h> 2 int main() 3 { 4 int jiech=1,i=1; 5 long int S=0; 6 do 7 { 8 jiech*=i; 9 S+=jiech; 10 i+=1; 11 } 12 while(i<=10); 13 printf("%ld\n",S); 14 return 0; 15 }
结果:4037913
标签:std 阶乘 ++ 循环 log clu i++ printf logs
原文地址:http://www.cnblogs.com/Bird-Xu/p/6502081.html