- 博客(65)
- 收藏
- 关注
原创 SDUT 一维数组之众数
知识点:巧妙地计数方法。#include <stdio.h>#include <stdlib.h>int main(){ int i,n,t,x,max; while (scanf("%d",&n)!=EOF) { int a[1002]={0}; for (i=1;i<=n;i++) { scanf("%d",&x); a[x]++
2020-07-06 21:32:25
786
原创 SDUT 函数之计算组合数
#include <stdio.h>#include <stdlib.h>int f(int n,int m);int main(){ int N,i,n,m,t,jg; scanf("%d",&N); for (i=1;i<=N;i++) { scanf("%d%d",&n,&m); if (n<m) { t=n; .
2020-07-06 20:50:25
887
原创 SDUT 函数之计算表达式
#include <stdio.h>#include <stdlib.h>#include <math.h>int main(){ double x,n,i; scanf("%lf%lf",&x,&n); for (i=1;i<=n;i++) { x=i+x; x=sqrt(x); } printf("%.2lf\n",x); return 0;}.
2020-07-06 20:39:30
252
原创 SDUT for循环之九九乘法表
#include <stdio.h>#include <stdlib.h>int main(){ int n,i,j,p; while (scanf("%d",&n)!=EOF) { for (i=1;i<=n;i++) { p=0; for (j=1;j<=i;j++) { p++; .
2020-07-06 20:28:50
809
原创 SDUT for循环之完美的素数
#include <stdio.h>#include <stdlib.h>int f(int x);int ff(int x);int main(){ int x; while(scanf("%d",&x)!=EOF) { if (f(x)&&ff(x)) { printf("YES\n"); }else printf("NO\n"); } .
2020-07-05 20:18:45
569
原创 SDUT for循环之余弦
#include <stdio.h>#include <stdlib.h>int main(){ int n,i; double x,s,a,p,b; while(scanf("%lf%d",&x,&n)!=EOF) { s=1.0000;a=b=1; for (i=1;i<=n;i++) { if (i%2==0) { .
2020-07-05 20:11:37
208
原创 SDUT for循环之水仙花数
#include <stdio.h>#include <stdlib.h>int main(){ int m,n,t,i,p,a,b,c; while (scanf("%d%d",&m,&n)!=EOF) { p=0; if (m>n) { t=m; m=n; n=t; } for.
2020-07-05 20:01:12
501
原创 SDUT for循环之打印菱形
#include <stdio.h>#include <stdlib.h>int main(){ int n,i,j,z; scanf("%d",&n); for (i=1;i<=n;i++) { for (j=1;j<=n-i;j++) { printf(" "); } for (z=1;z<=2*i-1;z++) .
2020-07-05 19:40:15
175
原创 SDUT for循环之分数序列
#include <stdio.h>#include <stdlib.h>int main(){ int a=2,b=1,i,n; double t,s=0; scanf("%d",&n); for (i=1;i<=n;i++) { t=1.0*a/b; s=s+t; t=a; a=a+b; b=t; } printf("%.6.
2020-07-05 19:33:48
449
原创 SDUT for循环之猜糖块
#include <stdio.h>#include <stdlib.h>int main(){ int n,i,s=0; scanf("%d",&n); for (i=0;s<=n;i++) { s=s+i*i; } printf("%d\n",i-2); return 0;}
2020-07-05 19:28:07
280
1
原创 SDUT for循环之圆周率
#include <stdio.h>#include <stdlib.h>int main(){ double s=0,t; int i,n; scanf("%d",&n); for (i=1;i<=n;i++) { t=1.0/(4*i-3)-1.0/(4*i-1); s=s+t; } printf("%.5lf\n",s*4); return 0;}
2020-07-05 19:24:41
234
原创 SDUT for循环之绝对值的最大值
#include <stdio.h>#include <stdlib.h>int main(){ int n,i,x,max,fx,fxx,jx,jxx; scanf("%d",&n); scanf("%d",&x); fx=x; if (x<0) { jx=-x; }else jx=x;max=jx; for (i=2;i<=n;i++) { scanf("%d",.
2020-07-05 18:11:00
300
原创 SDUT for循环之最大公约数与最小公倍数
#include <stdio.h>#include <stdlib.h>int main(){ int a,b,max,min,i,t; scanf("%d%d",&a,&b); if (a>b) { t=a; a=b; b=t; } max=1; for (i=1;i<=a;i++) { if (a%i==0&&b%i==0).
2020-07-05 18:02:51
633
原创 SDUT for循环之简单计算
#include <stdio.h>#include <stdlib.h>int main(){ int x,i,max,min,p,n,s; scanf("%d",&n); scanf("%d",&x); max=x;min=x;s=x; for (i=2;i<=n;i++) { scanf("%d",&x); if (x>max) { m.
2020-07-05 17:56:15
298
原创 SDUT for循环之数列求和
#include <stdio.h>#include <stdlib.h>int main(){ int a,s=0,i,t=0,n; scanf("%d\n%d",&a,&n); for (i=1;i<=n;i++) { t=10*t+a; s=s+t; } printf("%d\n",s); return 0;}
2020-07-05 17:51:32
518
原创 SDUT while循环之N^3问题
#include <stdio.h>#include <stdlib.h>int main(){ int x,s=0,ys; scanf("%d",&x); x=x*x*x; while (x>0) { ys=x%10; s=s+ys*ys*ys; x=x/10; } printf("%d\n",s); return 0;}
2020-07-05 17:37:41
178
原创 SDUT 选择结构之某年某月的天数
#include <stdio.h>#include <stdlib.h>int main(){ int year,month,day; scanf("%d\\%d",&year,&month); switch(month) { case 2:;if((year%4==0&&year%100!=0)|| (year%4==0&&year%100==0&&year%400=.
2020-07-05 16:06:53
175
原创 SDUT 选择结构之闰年
#include <stdio.h>#include <stdlib.h>int main(){ int year; scanf("%d",&year); if ((year%4==0&&year%100!=0)|| (year%4==0&&year%100==0&&year%400==0)|| (year%4!=0&&year%400==0)) { p..
2020-07-05 15:55:43
119
原创 SDUT 选择结构之求三个整数的最大值
知识点:数的交换。#include <stdio.h>#include <stdlib.h>int main(){ int a,b,c,t; scanf("%d,%d,%d",&a,&b,&c); if (a<b) { t=a; a=b; b=t; } if (a<c) { t=a; a=c; c=t; }
2020-07-05 15:46:22
254
原创 SDUT 选择结构之时间间隔
#include <stdio.h>#include <stdlib.h>int main(){ int s,f,m,s1,f1,m1,sum,s2,f2,m2; scanf("%d:%d:%d",&s,&f,&m); scanf("%d:%d:%d",&s1,&f1,&m1); sum=(s*3600+f*60+m)-(s1*3600+f1*60+m1); if (sum<0) {.
2020-07-05 15:41:44
2747
原创 SDUT 顺序结构之实数的输出与占位
知识点:占位。#include <stdio.h>#include <stdlib.h>int main(){ double x; scanf("%lf",&x); printf("%lf\n",x); printf("*%10.3lf*\n",x); printf("*%-10.3lf*\n",x); return 0;}
2020-07-05 15:21:47
364
原创 SDUT 顺序结构之单个字母大小写转换
知识点:单个字母大小写转换。#include <stdio.h>#include <stdlib.h>int main(){ char ch; ch=getchar (); putchar (ch-32); return 0;}
2020-07-05 15:15:54
390
原创 SDUT 顺序结构之单个字符的输入与输出
知识点:getchar和putchar的使用。#include <stdio.h>#include <stdlib.h>int main(){ char ch; ch=getchar(); putchar(ch); return 0;}
2020-07-05 15:11:29
2964
原创 SDUT 顺序结构之圆柱体计算
知识点:①define的使用。 ②保留几位小数。#include <stdio.h>#include <stdlib.h>#define P 3.1415926int main(){ double r,h,dz,dm,cm,v; scanf("%lf%lf",&r,&h); dz=2*P*r; dm=P*r*r; cm=dz*h; v=dm*h; printf("%.2lf %.2lf %.2lf %
2020-07-05 15:06:03
248
原创 SDUT 顺序结构之逆置正整数
#include <stdio.h>#include <stdlib.h>int main(){ int x,b,s,g; scanf("%d",&x); b=x/100; s=x/10%10; g=x%10; printf("%d\n",g*100+s*10+b); return 0;}
2020-07-05 14:47:29
296
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅