摘要: /* 求解数列1+1/(1+2)+1/(1+2+3)+...... */ #include <stdio.h> double fun(int n){ double s=0; int i,a=0; for(i=1;i<=n;i++){ a=a+i; s=s+1.0/a; } return s; } i 阅读全文
posted @ 2020-07-27 18:50 薄眠抛却陈年事。 阅读(800) 评论(0) 推荐(0) 编辑
摘要: /* 给出一个不多于5位的正整数 要求:(1)求出它是几位数; (2)分别输出每一位数字 (3)按照逆序*/ #include <stdio.h> #include <string.h> int main(){ char str[50]; scanf("%s",str); int i=0,count 阅读全文
posted @ 2020-07-27 18:42 薄眠抛却陈年事。 阅读(820) 评论(0) 推荐(0) 编辑
摘要: //输出1000以内的水仙花数 #include <stdio.h> #include <math.h> int main(){ int a,b,c,s,i; printf("水仙花数如下:\n"); for(i=100;i<=999;i++){ a=i/100; b=(i/10)%10; c=i% 阅读全文
posted @ 2020-07-27 15:44 薄眠抛却陈年事。 阅读(904) 评论(0) 推荐(0) 编辑
摘要: /* 计算:1+2+3+.....n+1*1+2*2+..m*m+1/1+1/2+...1/k; */ #include <stdio.h> double add(int n){ double s1=0.0; for(int i=1;i<=n;i++){ s1+=i; } return s1; } 阅读全文
posted @ 2020-07-27 15:18 薄眠抛却陈年事。 阅读(209) 评论(0) 推荐(0) 编辑
摘要: /* 计算1!+2!+3!+4!+5!+.....+20! 计算1!+2!+3!+...+n!; */ #include <stdio.h> float fun(float n){ float i,s=0,a=1; for(i=1;i<=n;i++){ a=a*i; s=s+a; } return 阅读全文
posted @ 2020-07-27 15:06 薄眠抛却陈年事。 阅读(298) 评论(0) 推荐(0) 编辑
摘要: /*计算s=2+22+222+2222......的值*/ //验证:n=5,s=2+22+222+2222+22222=24690 #include <stdio.h> int main(){ int i,n,a=0,s=0; printf("计算s=2+22+222+2222+....的值,现在 阅读全文
posted @ 2020-07-27 14:59 薄眠抛却陈年事。 阅读(643) 评论(0) 推荐(0) 编辑
摘要: //China!转化为Glmre! #include <stdio.h> int main(){ char c; while((c=getchar())!='\n'){ if(c>='a'&&c<='z'||c>='A'&&c<='Z'){ if(c>='w'&&c<='z'||c>='W'&&c< 阅读全文
posted @ 2020-07-27 14:19 薄眠抛却陈年事。 阅读(456) 评论(0) 推荐(0) 编辑
摘要: /*按公式计算pi的值:pi/4=1-1/3+1/5-1/7......*/ #include <stdio.h> #include <math.h> int main(){ double pi,s=0; double a=-1.0; int i=1; for(;fabs(a/i)>1e-6;){/ 阅读全文
posted @ 2020-07-27 14:07 薄眠抛却陈年事。 阅读(867) 评论(0) 推荐(0) 编辑
摘要: #include <stdio.h> #include <math.h> //键盘任意输入一个整数,判断其是否为素数 int main(){ int n,i,flag=1; printf("请任意输入一个整数,判断其是否为素数:"); scanf("%d",&n); for(int i=2;i<=s 阅读全文
posted @ 2020-07-27 13:57 薄眠抛却陈年事。 阅读(2441) 评论(0) 推荐(0) 编辑
摘要: 885程序设计考点狂背 最大公数与最大公倍数 地址1: 计算s=2+22+222+2222......的值验证:n=5,s=2+22+222+2222+22222=24690 地址 键盘任意输入一个整数,判断其是否为素数 地址: 计算1!+2!+3!+...+n! 地址 按公式计算pi的值 地址 计 阅读全文
posted @ 2020-07-27 13:05 薄眠抛却陈年事。 阅读(1284) 评论(0) 推荐(1) 编辑
摘要: /* 求两个不同正整数的最大公约数和最小公倍数 */ #include <stdio.h> int max_gys(int m,int n); int min_gbs(int m,int n); int main(){ int m,n; int gys,gbs; printf("请输入2个不同的正整 阅读全文
posted @ 2020-07-27 13:03 薄眠抛却陈年事。 阅读(417) 评论(0) 推荐(0) 编辑