摘要: #include<stdio.h> int main() { int N,i,a; int sum=0; int count=0; scanf("%d",&N); do { a=N%10; N=N/10; sum=a+sum; count++; }while(N!=0); printf("%d %d 阅读全文
posted @ 2020-03-11 23:27 金桔绒绒 阅读(1543) 评论(0) 推荐(0)
摘要: #include<stdio.h>//求整数段和 int main() { int i,a,b; int sum=0; int count=0; scanf("%d %d",&a,&b); for(i=a;i<=b;i++) { printf("%5d",i); count=count+1; if( 阅读全文
posted @ 2020-03-11 23:25 金桔绒绒 阅读(569) 评论(0) 推荐(0)
摘要: #include<stdio.h> #include<math.h> int main() { int N; char sex; double height; int i; scanf("%d",&N); for(i=1;i<=N;i++) { getchar();//吃掉之前scanf输入的空格 阅读全文
posted @ 2020-03-11 23:23 金桔绒绒 阅读(241) 评论(0) 推荐(0)
摘要: #include<stdio.h> int main(){ int m,n,i,j,k=0,count=0; scanf("%d %d",&m,&n); for(i=m;i<=n;i++){//循环找区间内素数 for(j=2;j<i;j++){//循环判断素数:只能被1和自身整除 if(i%j== 阅读全文
posted @ 2020-03-09 22:54 金桔绒绒 阅读(3451) 评论(0) 推荐(0)
摘要: #include<stdio.h> int main() { int m,i; int sum=0; scanf("%d",&m); for(i=1;i<=m;i++) { sum=sum+Fact(i); } printf("%d",sum); return 0; } int Fact(int n 阅读全文
posted @ 2020-03-08 23:11 金桔绒绒 阅读(738) 评论(0) 推荐(0)
摘要: #include<stdio.h> int main() { int m; long ret; printf("Input m:"); scanf("%d",&m); ret = Fact(m); printf("%d!=%ld\n",m,ret); return 0; } long Fact(in 阅读全文
posted @ 2020-03-08 23:05 金桔绒绒 阅读(335) 评论(0) 推荐(0)
摘要: #include<stdio.h> #include<math.h> int main() { int n,i; double sum=0; scanf("%d",&n); for(i=1;i<=n;i=i+1)//没有分号 { sum=1.0/i+sum;//是1.0/i,不然i增大,1/i仍然为 阅读全文
posted @ 2020-03-08 09:58 金桔绒绒 阅读(1039) 评论(0) 推荐(0)
摘要: #include<stdio.h> int main(){ int l,u; int f; float c; scanf("%d %d",&l,&u); if(l<=u){ printf("fahr celsius\n"); for(f=l;f<=u;f+=2){ c=5*(f-32)*1.0/9; 阅读全文
posted @ 2020-03-08 09:57 金桔绒绒 阅读(1278) 评论(0) 推荐(0)
摘要: a,b值互换 #include<stdio.h>//传值调用 #include<stdlib.h> #include<math.h> void swap(int x,int y)//设置函数 { int tmp=0; tmp=x; x=y; y=tmp; printf("INit x=%d,y=%d 阅读全文
posted @ 2020-03-08 09:55 金桔绒绒 阅读(154) 评论(0) 推荐(0)
摘要: #include<stdio.h>//2-09break语句成绩判断 int main() { int a,grade; scanf("%d",&a); grade=a/10; switch(grade) { case 10: case 9: printf("A"); break; case 8: 阅读全文
posted @ 2020-03-06 21:16 金桔绒绒 阅读(448) 评论(0) 推荐(0)