mlfk.net
当前位置:首页 >> C语言编程题:输入一个正整数n,输出1+1/2+2/3+3/4... >>

C语言编程题:输入一个正整数n,输出1+1/2+2/3+3/4...

#includeint main(){ int n; double sum=0;//记录总和初始值为0 printf("输入n的值:"); scanf("%d",&n); for(int i=1;i

#include main() { int n,i; double r=0,x; scanf("%d",&n); for(i=1;i

#include int main(void) { int n; scanf("%d", &n); printf("", (1 + n) * n / 2); return 0; }

#include"stdio.h" int jiechen(int n) { int z = 0; if (n == 1) { z = 1; } else { z = n * jiechen(n - 1); } return z; } main() { printf("输入n:\n"); int n = 0; scanf("%d", &n); int z = jiechen(n); printf("结果是:%d", z); }

#include int main(void) { int n; int i = 0, sum = 0; scanf("%d", &n); for (i = 0; i

main(){ int k,flag=1,n;float s=0;scanf("%d",&n);for(k=1;k

#include int main() { int n,sum=0; scanf("%d",&n); while(n) { sum+=n%10; n/=10; } printf("%d\n",sum); return 0; }

#include int main() { double sum=0,temp; int n,i,j; scanf("%d",&n); for(i=1;i

#include int main() { int i,n,de,flag; double item,pi; de=1; flag=1; item=1.0; pi=0; scanf("%d",&n); for(i=1;i

so easy,不过要使用到迭代,也是有点复杂的 int i,sum=0;void addN(int N){ if(N==1) return; for(i=1;i

网站首页 | 网站地图
All rights reserved Powered by www.mlfk.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com