自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(30)
  • 资源 (1)
  • 收藏
  • 关注

原创 【算法笔记】codeup 问题 J: 例题6-9 字符串求最大值

#include <stdio.h>#include <string.h>int main(){ char s1[100], s2[100], s3[100]; fgets(s1, 100, stdin); fgets(s2, 100, stdin); fgets(s3, 100, stdin); int cmp = strcmp(s1, s2); if (cmp > 0) { cmp = strc

2022-01-11 16:32:07 194

原创 【算法笔记】codeup 问题 I: 例题6-4 矩阵转置

#include <stdio.h>int main(){ int a1[2][3], a2[3][2]; for (int i = 0; i < 2; i++) { for (int j = 0; j < 3; j++) { scanf("%d", &a1[i][j]); a2[j][i] = a1[i][j]; } } for (i

2022-01-11 16:30:56 175

原创 【算法笔记】codeup 问题 H: 例题6-3 冒泡排序

#include <stdio.h>int main(){ int a[10], temp; for (int i = 0; i < 10; i++) { scanf("%d", &a[i]); } for (int i = 0; i < 10 - 1; i++) { for (int j = 0; j < 10 - 1 - i; j++) {

2022-01-11 16:29:58 84

原创 【算法笔记】codeup 问题 G: 例题6-2 数组求解Fibonacci数列问题

#include <stdio.h>int main(){ int a[20]; a[0] = a[1] = 1; for (int i = 2; i < 20; i++) { a[i] = a[i - 1] + a[i - 2]; } for (int i = 0; i < 20; i++) { printf("%d\n", a[i]); } return 0;}

2022-01-11 16:28:26 137

原创 【算法笔记】codeup 问题 F: 例题6-1 逆序输出数组元素

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

2022-01-11 16:26:46 124

原创 【算法笔记】codeup 习题6-13 字符串比较

#include <stdio.h>int main(){ char str1[100], str2[100]; fgets(str1, 100, stdin); fgets(str2, 100, stdin); for (int i = 0; i < 100; i++) { if (str1[i] == '\n' && str2[i] != '\n') { printf

2022-01-11 16:26:13 63

原创 【算法笔记】codeup 问题 D: 习题6-12 解密

#include <stdio.h>#include <string.h>int main(){ char str[100]; fgets(str, 100, stdin); int n = strlen(str); for (int i = 0; i < n; i++) { if ('a' <= str[i] && str[i] <= 'z') {

2022-01-11 16:25:11 147

原创 【算法笔记】 codeup 习题6-6 杨辉三角

#include <stdio.h>int main(){ int n; scanf("%d", &n); int a[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j <= i; j++) { if (j == 0 || j == i) { a[i][j] =

2022-01-11 16:24:16 181

原创 【算法笔记】codeup 问题 B: 习题6-5 数组元素逆置

#include <stdio.h>int main(){ int n[10]; for (int i = 0; i < 10; i++) { scanf("%d", &n[i]); } for (int i = 9; i >= 0; i--) { printf("%d ", n[i]); } return 0;}

2022-01-11 16:23:36 124

原创 【算法笔记】 codeup 习题6-4 有序插入

#include <stdio.h>int main(){ int n[10]; for (int i = 0; i < 10; i++) { scanf("%d", &i[n]); } for (int i = 0; i < 10; i++) { if (n[9] < n[i]) { int temp = n[i];

2022-01-11 16:22:19 60

原创 【算法笔记】 codeup 习题5-10 分数序列求和

#include <stdio.h>int main(){ //a为分子,b为分母 double a = 2, b = 1, sum = 0; for (int i = 1; i <= 20; i++) { sum += a / b; a = a + b; b = a - b; } printf("%.6f\n", sum); return 0;}

2022-01-03 15:26:07 171

原创 【算法笔记】 codeup 问题 H: 例题5-8 Fibonacci数列

#include <stdio.h>int main(){ //fa,fb先是表示第一项和第二项,在进入for循环后,fa、fb表示所求项的前两项,f表示所求项 int fa = 1, fb = 1, f, n; scanf("%d", &n); if (n == 1) { printf("%d\n", fa); } else if (n == 2) { printf("%d\n", f

2022-01-03 15:25:34 223

原创 【算法笔记】 codeup 问题 G: 例题5-7 求圆周率pi的近似值

#include <stdio.h>#include <math.h>int main(){ //n表示每一项,sign表示每一项的正负号 double n, pi = 0, sign = 1; for (int i = 1;; i++) { n = sign / (2 * i - 1); if (fabs(n) < 1e-6) { break; }

2022-01-03 15:24:40 181

原创 【算法笔记】 codeup 问题 F: 例题5-6 矩阵输出

#include <stdio.h>int main(){ for (int i = 1; i < 5; i++) { for (int j = 1; j < 6; j++) { printf("%3d", i * j); } printf("\n"); } return 0;}

2022-01-03 15:23:11 183

原创 【算法笔记】 codeup 例题5-1-5 连续自然数求和

#include <stdio.h>int main(){ int N = 0, sum = 0; while (sum < 1000) { N++; sum += N; } printf("%d", N); return 0;}

2022-01-03 15:21:51 152

原创 【算法笔记】 codeup 问题 D: 例题5-1-4 连续自然数求和

#include <stdio.h>int main(){ int N, sum = 0; scanf("%d", &N); for (int i = 1;; i++) { if (i > N) { break; } sum += i; } printf("%d", sum); return 0;}

2022-01-03 15:21:18 379

原创 【算法笔记】 codeup 例题5-1-3 连续自然数求和

#include <stdio.h>int main(){ int sum = 0; for (int n = 100; n > 0; n--) { sum += n; } printf("%d", sum); return 0;}

2022-01-03 15:20:35 169

原创 【算法笔记】 codeup 问题 B: 例题5-1-2 连续自然数求和

#include <stdio.h>int main(){ int n = 100, sum = 0; do { sum += n; n--; } while (n > 0); printf("%d", sum); return 0;}

2022-01-03 15:19:27 235

原创 【算法笔记】 codeup 例题5-1-1 连续自然数求和

#include <stdio.h>int main(){ int n = 100, sum = 0; while (n > 0) { sum += n; n--; } printf("%d", sum); return 0;}

2021-12-27 13:48:36 377

原创 【算法笔记】 codeup 问题 E: 习题4-10-1 奖金计算

#include <stdio.h>int main(){ double n, a, a10, a20, a40, a60, a100; a = 0; a10 = 100000 * 0.1; a20 = a10 + (200000 - 100000) * 0.075; a40 = a20 + (400000 - 100000) * 0.05; a60 = a40 + (600000 - 400000) * 0.03; a100 =

2021-12-27 13:47:23 304

原创 【算法笔记】 codeup 习题4-4 三个整数求最大值

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

2021-12-27 13:46:04 372

原创 【算法笔记】codeup 例题4-3 比较交换3个实数值,并按序输出

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

2021-12-25 16:43:36 47

原创 【算法笔记】codeup 例题4-2 比较交换实数值

#include <stdio.h>int main(){ double a, b; scanf("%lf%lf",&a,&b); if (a < b) { printf("%.2f %.2f", a, b); } else { printf("%.2f %.2f", b, a); } return 0;}

2021-12-25 16:40:30 196

原创 【算法笔记】codeup 例题4-1 一元二次方程求根

#include <stdio.h>#include <math.h>int main(){ double a,b,c,delta,r1,r2; scanf("%lf%lf%lf",&a,&b,&c); delta=b*b-4*a*c; r1=(-b+sqrt(delta))/(2*a); r2=(-b-sqrt(delta))/(2*a); if (delta<0) {

2021-12-25 16:38:38 60

原创 【算法笔记】codeup 例题3-9 字符输入输出

#include <stdio.h>int main(){ char str[3]; scanf("%s", str); printf("%s\n", str); return 0;}

2021-12-25 16:36:16 154

原创 【算法笔记】codeup 例题3-5 求一元二次方程的根

#include <stdio.h>#include <math.h>int main(){ double a, b, c, r1, r2; scanf("%lf%lf%lf", &a, &b, &c); r1 = (-b + sqrt(b * b - 4 * a * c)) / (2 * a); r2 = (-b - sqrt(b * b - 4 * a * c)) / (2 * a); printf("r1=%7.2f\nr2=%7

2021-12-25 16:35:04 390

原创 【算法笔记】codeup 例题1-2-2 求两整数数之和(2)

#include <stdio.h>int main(){ int a, b; scanf("%d%d", &a, &b); printf("%d", a + b); return 0;}

2021-12-25 16:29:45 50

原创 【算法笔记】codeup 例题1-2-1 求两个整数之和(1)

#include <stdio.h>int main(){ int a, b, sum; a = 123; b = 456; sum = a + b; printf("%d", sum); return 0;}

2021-12-25 16:28:39 143

原创 【算法笔记】 codeup 问题 B: 例题1-1-2 按要求输出信息(2)

#include <stdio.h>int main(){ printf("********************\n\Very Good!\n\********************\n"); return 0;}

2021-12-25 16:26:33 168

原创 【算法笔记】 codeup 例题1-1-1 按要求输出信息(1)

#include <stdio.h>int main(){ printf(" This is my first c program!"); return 0;}

2021-12-25 16:24:51 163

空空如也

空空如也

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

TA关注的人

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