自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 第2章 C语言基本概念

基本概念: 预处理指令、函数、变量和语句。 后几章会有更详细的描述。

2021-06-03 16:24:04 108

原创 7-30 念数字 (15 分)

#include <stdio.h>char c[][5] = {"ling", "yi", "er", "san", "si", "wu", "liu", "qi", "ba", "jiu",};int main() { long long n, num = 0; int ans[10000]; scanf("%lld", &n); if (n < 0) { printf("fu "); n = -n;.

2021-06-03 12:58:00 146

原创 7-29 二分法求多项式单根 (20 分)

#include <stdio.h>double a3, a2, a1, a0;double calculate(double x) { return a3 * x * x * x + a2 * x * x + a1 * x + a0;}int main(void) { double a, b, result; scanf("%lf %lf %lf %lf", &a3, &a2, &a1, &a0); scan.

2021-06-03 12:57:52 196

原创 7-28 求整数的位数及各位数字之和 (15 分)

#include <stdio.h>int main() { int n, count, sum; sum = 0; count = 0; scanf("%d", &n); while (n != 0) { count++; sum += n % 10; n /= 10; } printf("%d %d\n", count, sum); return 0;}.

2021-06-03 12:57:42 242

原创 7-27 兔子繁衍问题 (15 分)

#include <stdio.h>int f(int n){ if (n == 1 || n == 2) return 1; else return f(n - 1) + f(n - 2);}int main(){ int num, n = 1; scanf("%d", &num); while (f(n) < num) { n++; } printf("%d", n); retur.

2021-06-02 23:13:43 172

原创 7-26 最大公约数和最小公倍数 (15 分)

#include <stdio.h>int main(){ int a, b, c, m, t, gcd, lcm; scanf("%d %d", &a, &b); if (a < b) { t = a; a = b; b = t; } m = a * b; c = a % b; while (c != 0) { a = b; b = c; c...

2021-06-02 23:13:24 183

原创 7-25 求奇数和 (15 分)

#include <stdio.h>int main(){ int number, sum; while(1) { scanf("%d", &number); if (number < 0 || number == 0){ printf("%d", sum); return 0; } else if (number % 2 == 0) sum = sum + 0; else if.

2021-06-02 23:13:14 209

原创 第1章 C语言概述

C语言的起源、标准化(设计目标)、基于C的语言(多年的发展) C语言的优缺点、高效地使用C语言本章不需要过多赘述,对实际编写程序的用途并不大,可快速略过。

2021-06-02 21:49:08 95

原创 《C语言程序设计:现代方法》笔记总汇查找

关于本书的总汇查找C Programming: A Modern Approach - Second Edition (knking.com)

2021-06-02 21:30:41 184

原创 7-24 猜数字游戏 (15 分)

if (guess == number) { if (guesstimes == 1) { printf("Bingo!\n"); } else if (guesstimes <= 3) { printf("Lucky You!\n"); } else { printf...

2021-06-02 20:52:09 170

原创 7-23 分段计算居民水费 (10 分)

#include <stdio.h>int main(){ double x, y; scanf("%lf", &x); if (x <= 15) { y = 4 * x / 3; } else { y = 2.5 * x - 17.5; } printf("%.2f", y); return 0;}

2021-06-02 20:51:39 174

原创 7-22 用天平找小球 (10 分)

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

2021-06-02 20:51:23 96

原创 7-21 超速判断 (10 分)

#include <stdio.h>int main(){ int speed; scanf("%d", &speed); if (speed > 60){ printf("Speed: %d - Speeding\n", speed); } else { printf("Speed: %d - OK\n", speed); } return 0;}

2021-06-02 20:51:11 158

原创 7-20 简单计算器 (20 分)

#include <stdio.h>int main(){ int a, b; char c; scanf("%d", &a); while (scanf("%c", &c)) { switch (c) { case '+': scanf("%d", &b); a += b; break; case '-': scanf("%d", &b); a -= b; break; case '*': sc.

2021-06-02 10:48:52 121

原创 7-19 计算天数 (15 分)

#include <stdio.h>int main(){ int year, month, day, num; int two; scanf("%d /%d /%d", &year, &month, &day); if((year % 4 == 0 && year % 100 != 0) || year % 400 == 0){ two = 29; } else{ two = 28; } sw.

2021-06-01 20:48:13 134

原创 7-18 出租车计价 (15 分)

#include <stdio.h>int main(){ double km, fare; int min; scanf("%lf %d", &km, &min); if(km <= 3){ fare = 10 + min / 5 * 2; } else if(km <= 10){ fare = 10 + (km - 3) * 2 + min / 5 * 2; } else{ fare = 10 + .

2021-06-01 20:48:04 181

原创 7-17 成绩转换 (15 分)

#include <stdio.h>int main(){ int grade; scanf("%d", &grade); switch (grade / 10) { case 10: case 9: printf("A\n"); break; case 8: printf("B\n"); break; case 7: printf("C\n"); .

2021-06-01 20:47:45 124

原创 7-16 计算符号函数的值 (10 分)

#include <stdio.h>int main(){ int n, sign; scanf("%d", &n); if(n < 0){ sign = -1; } else if(n > 0){ sign = 1; } else{ sign = 0; } printf("sign(%d) = %d", n, sign); return 0;}

2021-06-01 20:47:32 139

原创 7-15 BCD解密 (10 分)

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

2021-06-01 13:31:12 125 2

原创 7-14 然后是几点 (15 分)

#include <stdio.h>int main(){ int x, y; scanf("%d %d", &x, &y); int hour = x / 100; int min = x % 100; if(y > 0){ int inhour = (min + y) /60; int inmin = (min + y) % 60; printf("%d%02d\n", hour + inhour, inmin.

2021-06-01 13:30:40 238

原创 7-13 后天 (5 分)

#include <stdio.h>int main(){ int d, at; scanf("%d", &d); if(d <= 5) at = d + 2; else at = d - 7 + 2; printf("%d", at); return 0;}

2021-06-01 13:30:08 188

原创 7-12 日期格式化 (5 分)

#include <stdio.h>int main(){ int year, month, day; scanf("%d-%d-%d", &month, &day, &year); printf("%d-%02d-%02d", year, month, day); return 0;}

2021-06-01 13:29:39 292

原创 7-11 计算平均分 (5 分)

#include <stdio.h>int main(){ int math = 87; int eng = 72; int comp = 93; int average; average = (math + eng + comp) / 3; printf("math = %d, eng = %d, comp = %d, average = %d", math, eng, comp, average); return 0;}

2021-06-01 13:28:51 227

原创 7-10 算术入门之加减乘除 (10 分)

#include <stdio.h>int main(){ 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); if (a % b == 0){ printf("%d / %d = %d\.

2021-06-01 13:23:45 258

原创 7-9 求整数均值 (10 分)

#include <stdio.h>int main(){ int a, b, c, d, sum; double average; scanf("%d %d %d %d", &a, &b, &c, &d); sum = a + b + c + d; average = sum / 4.0; printf("Sum = %d; Average = %.1f", sum, average); return 0;}..

2021-05-31 23:29:35 131

原创 7-8 是不是太胖了 (5 分)

#include <stdio.h>int main(){ int height; double weight; scanf("%d", &height); weight =( height - 100 ) * 0.9 * 2; printf("%.1f", weight); return 0;}

2021-05-31 23:28:10 109

原创 7-7 计算摄氏温度 (10 分)

#include <stdio.h>int main(){ int centigrade, celsius; scanf("%d", &centigrade); celsius = 5 * (centigrade - 32) / 9; printf("Celsius = %d", celsius); return 0;}

2021-05-31 23:26:47 327

原创 7-6 厘米换算英尺英寸 (15 分)

#include <stdio.h>int main(){ int centi; int foot, inch; scanf("%d", &centi); foot = centi / 30.48 ; inch = (centi / 30.48 - foot) * 12 ; printf("%d %d", foot, inch); return 0;}

2021-05-31 23:25:12 195

原创 7-5 输出倒三角图案 (5 分)

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

2021-05-31 23:24:03 133

原创 7-4 输出菱形图案 (5 分)

#include <stdio.h>int main(){ printf(" A\nA A\n A\n"); return 0; }

2021-05-31 23:22:03 117

原创 7-3 输出带框文字 (5 分)

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

2021-05-31 23:19:04 182

原创 7-2 I Love GPLT (5 分)

#include <stdio.h>int main(){ printf("I\n \nL\no\nv\ne\n \nG\nP\nL\nT\n"); return 0; }

2021-05-31 23:17:55 240

原创 7-1 重要的话说三遍 (5 分)

2021-05-31这道超级简单的题目没有任何输入。你只需要把这句很重要的话 —— “I'm gonna WIN!”——连续输出三遍就可以了。注意每遍占一行,除了每行的回车不能有任何多余字符。

2021-05-31 16:02:14 379

原创 浙大c语言pat试题汇总

2021.05.317-01

2021-05-31 15:53:31 2749

空空如也

空空如也

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

TA关注的人

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