- 博客(14)
- 收藏
- 关注
原创 练习2-14
#include<stdio.h>int main(void){ int n,i; double sum; scanf("%d",&n); sum=0; for(i=1;i<=n*2;i=i+2){ sum=sum+1.0/i; } printf("sum = %.6lf",sum); return 0;}注意事项:1.前n项和不是前n个奇数项和所以...
2022-05-24 21:24:11 53
原创 练习2-13
#include<stdio.h>int main(void){ int n,i; double sum,item; scanf("%d",&n); sum=0; for(i=1;i<=n;i++){ item=1.0/i; sum=sum+item; } printf("sum = %.6f",sum); return 0;...
2022-05-24 20:53:35 55
原创 练习2-12
#include<stdio.h>int main(void){ int lower,upper,fahr; double celsius; scanf("%d %d",&lower,&upper); if(lower<=upper){ printf("fahr celsius\n"); for(fahr=lower;fahr<=upper;fahr=fahr+2){ ...
2022-05-24 20:36:17 534
原创 练习2-10
语言:#include<stdio.h>int main(void){ double x,y; scanf("%lf",&x); if(x==0){ y=0; }else{ y=1/x; } printf("f(%.1f) = %.1f",x,y); return 0;}注意:1.记得加入scanf(重点号)...
2022-05-23 21:59:09 59
原创 练习2-9
语言:#include<stdio.h>int main(void){ int A,B; scanf("%d %d",&A,&B); printf("%d + %d = %d\n",A,B,A+B); printf("%d - %d = %d\n",A,B,A-B); printf("%d * %d = %d\n",A,B,A*B); printf("%d / %d = %d\n",A,B,A/B);...
2022-05-23 21:57:39 65
原创 练习2-6
程序:#include<stdio.h>int main(void){ int t,a; double height; a=10; t=3; height=(a*t*t)/2; printf("height = %.2f",height); return 0;}注意:1.算式前赋值2.类型和后面对应:int→d,double→lf...
2022-05-23 21:29:21 107
原创 练习2-4
语言:#include<stdio.h>int main(void){ int fahr,celsius; fahr=150; celsius=5*(fahr-32)/9; printf("fahr = 150, celsius = %d",celsius); return 0;}注意:1.公式之前先赋值
2022-05-23 20:57:51 61
原创 练习2-1
语言:#include<stdio.h>int main(void){ printf("Programming in C is fun!"); return 0;}注意知识点:1.程序框架(所有程序都要用到):第二章开头
2022-05-23 20:55:49 84
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人