自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(7)
  • 收藏
  • 关注

原创 输出N以内所有素数

#include <stdio.h>int main(){ int i,j,s,n,a; scanf("%d", &n); for (i = 2; i <= n; i++) { a = 0; for (j = 2; j < i; j++) { if (i%j == 0) a++; } if (a == 0) { printf("%d ", i); } } return 0;}

2022-01-16 11:08:18 1467

原创 一球从M米高度自由下落,每次落地后返回原高度的一半,再落下。 它在第N次落地时反弹多高?共经过多少米? 保留两位小数

#include <stdio.h>int main(){ int i,n,t; float h,s=0; scanf("%f %d", &h, &t); for (i = 1; i <= t; i++) { s = s + h + 0.5*h; h = 0.5*h; } s = s - h; printf("%.2f %.2f",h ,s); return 0;}

2022-01-15 16:40:14 974 1

原创 有一分数序列: 2/1 3/2 5/3 8/5 13/8 21/13...... 求出这个数列的前N项之和,保留两位小数

#include <stdio.h>int main(){ float a,b,s=0.0; int m ,n; scanf("%d", &n); a = 2; b = 1; for (int i = 1; i <= n; i++) { s=s+(a/b); m = a + b; b = a; a = m; } printf("%.2f",s);}

2022-01-13 21:00:01 2324

原创 求最大公约数和最小公倍数

# include <stdio.h>int main(){ int m, n, x, y, max, min,i; scanf("%d %d", &m, &n); max = m > n ? m : n; min = m > n ? n : m; x = 1; if (max%min == 0) { x = min; y = max; } else { for (i = 1; i <= min; i++) { if.

2022-01-13 12:53:15 200

原创 给出一个不多于5位的整数,要求 1、求出它是几位数 2、分别输出每一位数字 3、按逆序输出各位数字,例如原数为321,应输出123

#include<stdio.h>int main(){ int a[4], t, n,m, count = 0, i = 0; scanf("%d", &n); t = n; m = n; while (m) { a[i] = m % 10; m = m / 10; i++; } printf("%d\n", i); for (count = i-1; count >=0; count--) { printf("%d ", a[...

2022-01-12 19:30:16 454

原创 [递归]母牛的故事

有一头母牛,它每年年初生一头小母牛。每头小母牛从第四个年头开始,每年年初也生一头小母牛。请编程实现在第n年的时候,共有多少头母牛?#include <stdio.h>int main() { int s[100], n,i; while (scanf("%d", &n) != 0) { if (n == 0)break; s[1] = 1; s[2] = 2; s[3] = 3; for (i = 4; i <= n; i++) { s[i] =

2022-01-10 18:34:48 280

原创 输入三个数求最大值

#include<stdio.h>int main(){ int a, b, c, max; scanf("%d %d %d", &a, &b, &c); max = a; if (a < b) { max = b; if (b < c) { max = c; } } if (a < c) { max = c; if (c < b) { max = b; } } printf(.

2022-01-10 13:22:38 363

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除