
C语言编程题
C语言编程题
happy 天堂
这个作者很懒,什么都没留下…
展开
-
2022-05-04_十进制与二进制数据的文件I/O
#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <math.h>#include <stdlib.h>#include <string.h>#include <time.h>#include <errno.h>#include <ctype.h>#include <assert.h>#include <stdbool.h.原创 2022-05-04 17:01:43 · 598 阅读 · 0 评论 -
2022-04-16_5排序算法合集
一、建立三个文件二、代码实现 1.Sort.c部分#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <math.h>#include <stdlib.h>#include <string.h>#include <time.h>#include <errno.h>#include <ctype.h>#include &l原创 2022-04-26 11:30:05 · 156 阅读 · 0 评论 -
2022-04-12_5-二叉树相关习题3
一、二叉树的构建及遍历作业内容二叉树的构建及遍历。描述编一个程序,读入用户输入的一串先序遍历字符串,根据此字符串建立一个二叉树(以指针方式存储)。 例如如下的先序遍历字符串: ABC##DE#G##F### 其中“#”表示的是空格,空格字符代表空树。建立起此二叉树以后,再对二叉树进行中序遍历,输出遍历结果。输入描述:输入包括1行字符串,长度不超过100。输出描述:可能有多组测试数据,对于每组数据, 输出将输入字符串建立二叉树后中序遍历的序列,每个字符后面都有一个空格。原创 2022-04-24 16:39:10 · 216 阅读 · 0 评论 -
2022-04-12_5-二叉树相关习题2
一、作业标题检查两颗树是否相同作业内容检查两颗树是否相同。给你两棵二叉树的根节点 p 和 q ,编写一个函数来检验这两棵树是否相同。如果两个树在结构上相同,并且节点具有相同的值,则认为它们是相同的。示例 1:输入:p = [1,2,3], q = [1,2,3]输出:true示例 2:输入:p = [1,2], q = [1,null,2]输出:false示例 3:输入:p = [1,2,1], q = [1,1,2]输出:fals..原创 2022-04-24 15:26:50 · 430 阅读 · 0 评论 -
2022-04-12_5-二叉树相关习题1
一、作业标题二叉树最大深度作业内容二叉树最大深度。给定一个二叉树,找出其最大深度。二叉树的深度为根节点到最远叶子节点的最长路径上的节点数。说明: 叶子节点是指没有子节点的节点。示例:给定二叉树 [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7返回它的最大深度3 。来源:力扣(LeetCode)/** * Definition for a binary tree node...原创 2022-04-24 11:01:02 · 98 阅读 · 0 评论 -
2022-04-09_二叉树及其功能的实现
一、创建三个文件二、代码实现1.BinaryTree.c部分#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <math.h>#include <stdlib.h>#include <string.h>#include <time.h>#include <errno.h>#include <ctype.h>#inc..原创 2022-04-24 10:27:45 · 172 阅读 · 0 评论 -
2022-04-09_建小堆实现Top-k问题
一、创建三个文件二、代码实现1.HeapTop_k.c#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <math.h>#include <stdlib.h>#include <string.h>#include <time.h>#include <errno.h>#include <ctype.h>#includ原创 2022-04-09 21:36:57 · 1234 阅读 · 0 评论 -
2022-04-07_建小堆实现数组降序
一、创建三个文件二、代码实现1.HeapSort.c#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <math.h>#include <stdlib.h>#include <string.h>#include <time.h>#include <errno.h>#include <ctype.h>#include .原创 2022-04-09 21:14:09 · 343 阅读 · 0 评论 -
2022-04-07_建大堆实现数组升序
一、创建三个文件二、代码实现1.HeapSort.c#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <math.h>#include <stdlib.h>#include <string.h>#include <time.h>#include <errno.h>#include <ctype.h>#include原创 2022-04-09 20:45:42 · 375 阅读 · 0 评论 -
2022-04-02_顺序表实现大堆
一、创建三个文件二、代码实现1.Heap.c部分#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <math.h>#include <stdlib.h>#include <string.h>#include <time.h>#include <errno.h>#include <ctype.h>#include原创 2022-04-09 17:37:09 · 863 阅读 · 0 评论 -
2022-04-02_顺序表实现小堆
一、创建三个文件二、代码实现1.Heap.c部分#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <math.h>#include <stdlib.h>#include <string.h>#include <time.h>#include <errno.h>#include <ctype.h>#includ...原创 2022-04-09 17:26:53 · 983 阅读 · 0 评论 -
2022-03-26_单链表实现队列(带目录版)
一、创建三个文件二、代码实现1.Queue.c部分#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <math.h>#include <stdlib.h>#include <string.h>#include <time.h>#include <errno.h>#include <ctype.h>#inclu...原创 2022-03-27 16:04:23 · 1435 阅读 · 0 评论 -
2022-03-24_数组栈的实现(带目录版)
一、创建三个文件二、代码实现1.Stack.c部分#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <math.h>#include <stdlib.h>#include <string.h>#include <time.h>#include <errno.h>#include <ctype.h>#include &.原创 2022-03-26 17:27:07 · 460 阅读 · 0 评论 -
2022-03-21_双链表的增删查改(带目录版)
题目名称:双链表的增删查改题目内容:带头+双向+循环链表增删查改实现第一步 创建三个文件 第二步 代码实现1.List.c部分#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <math.h>#include <stdlib.h>#include <string.h>#include <time.h>#include &l原创 2022-03-26 15:20:28 · 1431 阅读 · 0 评论 -
2022-03-12_2_单链表的增删查改(带目录版)
作业标题单链表的增删查改一、定义三个文件二、代码实现LinkList.c部分#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <math.h>#include <stdlib.h>#include <string.h>#include <time.h>#include <errno.h>#include <原创 2022-03-17 18:39:34 · 1327 阅读 · 0 评论 -
2022-03-12_单链表的增删查改
作业标题单链表的增删查改一、定义三个文件二、代码实现LinkList.c部分 #define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <math.h>#include <stdlib.h>#include <string.h>#include <time.h>#include <errno.h>#include <.原创 2022-03-16 21:08:58 · 845 阅读 · 0 评论 -
2022-02-09_顺序表
一、作业标题顺序表的增删查改第一步、创建三个程序文件第二步、实现程序test.c部分#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <math.h>#include <stdlib.h>#include <string.h>#include <time.h>#include <errno.h>#include &.原创 2022-03-11 21:38:43 · 219 阅读 · 0 评论 -
2022-02-18_文件的打开和关闭
一、作业标题通讯录作业内容1.实现通讯录的增删查改2.实现通讯录数据可以保存到文件,也可以从文件中加载数据。第一步、创建头文件和源文件第二步、编程实现text.c部分#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <math.h>#include <stdlib.h>#include <string.h>#include <.原创 2022-03-10 23:15:18 · 565 阅读 · 0 评论 -
C_2022_02_23 程序的编译(预处理操作)+链接(进阶)
一、作业标题交换奇偶位作业内容写一个宏,可以将一个整数的二进制位的奇数位和偶数位交换。#define Change_Odd_and_Even(n) (((n&(0xaaaaaaaa))>>1)|((n&(0x55555555))<<1))int main(){ int a = 0; printf("二进制奇偶位交换前,请输入一个数:\n"); scanf("%d", &a); printf("二进制奇偶位交换后:\n");原创 2022-03-09 17:41:36 · 148 阅读 · 0 评论 -
C_2022_01_24 动态内存管理(进阶)
一、作业标题模拟实现atoi作业内容模拟实现atoilong long My_atoi(char* str){ assert(str); //判断指针是否为空 if (*str == '\0') { return 0; //如果字符串为空指针,则返回0,表示转换失败 } int count1 = 0; int .原创 2022-03-09 16:20:53 · 119 阅读 · 0 评论 -
C_2022_01_23 位段
一、描述输入两个升序排列的序列,将两个序列合并为一个有序序列并输出。数据范围: 1 ≤ n, m≤ 1000 ,序列中的值满足 0 ≤ val ≤ 30000输入描述:输入包含三行,第一行包含两个正整数n, m,用空格分隔。n表示第二行第一个升序序列中数字的个数,m表示第三行第二个升序序列中数字的个数。第二行包含n个整数,用空格分隔。第三行包含m个整数,用空格分隔。输出描述:输出为一行,输出长度为n+m的升序序列,即长度为n的升序序列和长度为m的升序序列中的元素重新进行原创 2022-03-08 23:12:53 · 120 阅读 · 0 评论 -
C_2022_01_21 字符串&内存函数的介绍(进阶)
一、作业标题模拟实现memmove(说明:memmove是较早版本momcpy的升级版,现在VS里的memcpy等同于mommove,本文第二题实现的memcpy是较早版本的memcpy,就是因为较早版本的memcpy不完美,所以开发出memmove函数,不过之后也对memcpy进行了升级,功能已与memmove一样)作业内容模拟实现memmovevoid* My_memmove(void* Destination, void* source, size_t num){ voi原创 2022-03-08 22:50:02 · 235 阅读 · 0 评论 -
C_2022_01_19 字符串库函数的模拟实现
一、作业标题模拟实现strlen作业内容模拟实现strlen原创 2022-03-08 19:30:33 · 186 阅读 · 0 评论 -
C_2022_01_16 数组指针
作业标题字符串旋转结果作业内容写一个函数,判断一个字符串是否为另外一个字符串旋转之后的字符串。例如:给定s1 =AABCD和s2 = BCDAA,返回1给定s1=abcd和s2=ACBD,返回0.AABCD左旋一个字符得到ABCDAAABCD左旋两个字符得到BCDAAAABCD右旋一个字符得到DAABC//方法一int LRound(char* str1, char* str2, int len) //左旋遍历一次后,字符串所有的可能形式已经包含,不需要再右原创 2022-03-07 21:07:58 · 115 阅读 · 0 评论 -
C_2022_01_15 字符指针
一、作业标题字符串左旋作业内容实现一个函数,可以左旋字符串中的k个字符。例如:ABCD左旋一个字符得到BCDAABCD左旋两个字符得到CDAB#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <math.h>#include <stdlib.h>#include <string.h>#include <time.h>#include &l原创 2022-03-07 20:20:02 · 102 阅读 · 0 评论 -
C_2021_10_28 分支循环
一、题目:猜数字游戏内容:系统随机生成一个1-100的数字;手动输入猜想的数字,根据提示,直到猜中数字为止。#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <math.h>#include <stdlib.h>#include <string.h>#include <time.h>void game(){ int a = rand() % 1原创 2021-12-08 20:33:53 · 2553 阅读 · 0 评论 -
C_2021_11_21 实用调试技巧
一、作业标题strlen实现作业内容模拟实现库函数strlenint my_strlen(char * str){ int count = 0; while (*str != '\0') { count++; str++; } return count;}int main(){ char arr[100] = {0}; gets(arr); printf("%d", my_strlen(arr)); return 0;}二、原创 2021-12-12 22:53:33 · 127 阅读 · 0 评论 -
C_2021_10_24 初识C语言+分支和循环
一、作业标题从大到小输出作业内容写代码将三个整数数按从大到小输出。例如:输入:2 3 1输出:3 2 1int main(){ int a = 0; int b = 0; int c = 0; int tmp = 0; scanf("%d %d %d", &a, &b, &c); if (a < b) { tmp = a; a = b; b = tmp; } if (b < c) { tmp = b;原创 2021-12-07 11:16:37 · 359 阅读 · 0 评论 -
C_2021_10_26 分支和循环
一、作业标题数9的个数作业内容编写程序数一下 1到 100 的所有整数中出现多少个数字9int main(){ int i = 0; int count = 0; for (i = 1; i < 100; i++) { if (i % 10 == 9) { count++; } if (i / 10 == 9) { count++; } } printf("%d", count); return 0;}二、作业标原创 2021-12-08 11:14:21 · 306 阅读 · 0 评论 -
C_2021_11_07 数组+三子棋
作业标题三子棋作业内容完成三子棋游戏代码1.首先在源文件和头文件分别创建game.c、c_2021_12_11、game.h,如下图所示(这三个文件可以自己随意命名)。2.开始写代码//C_2021_12_11m模块#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <math.h>#include <stdlib.h>#include <string.h&g.原创 2021-12-11 12:12:28 · 2324 阅读 · 0 评论 -
C_2021_11_28 初阶段测评
一、描述不使用累计乘法的基础上,通过移位运算(<<)实现2的n次方的计算。数据范围:0≤n≤31。输入描述:一行输入整数n(0 <= n < 31)。输出描述:输出对应的2的n次方的结果。示例1输入:2输出:4示例2输入:10输出:1024int main(){ int i = 0; while (scanf("%d", &i) != EOF) { printf("%d\n", 1 <原创 2021-12-14 11:31:14 · 896 阅读 · 0 评论 -
C_2021_10_19 初识C语言
一、作业标题求两个数的较大值作业内容写一个函数求两个整数的较大值如:输入:10 20输出较大值:20int Max(int i, int j){ int k = 0; if (i > j) k = i; else k = j; return k;}int main(){ int x = 0; int y = 0; scanf("%d %d", &x, &y); printf("%d", Max(x, y));.原创 2021-12-06 10:10:11 · 160 阅读 · 0 评论 -
C_2021_11_25 数据的储存
一、描述老师给了小乐乐一个正整数序列,要求小乐乐把这个序列去重后按从小到大排序。但是老师给出的序列太长了,小乐乐没办法耐心的去重并排序,请你帮助他。输入描述:第一行包含一个正整数n,表示老师给出的序列有n个数。接下来有n行,每行一个正整数k,为序列中每一个元素的值。(1 ≤ n ≤ 105,1 ≤ k ≤ n)输出描述:输出一行,为去重排序后的序列,每个数后面有一个空格。示例1输入:42211输出:1 2 示例2输入:55432原创 2021-12-13 21:32:47 · 120 阅读 · 0 评论 -
C_2021_11_23 调试+数据的储存
一、作业标题杨辉三角作业内容在屏幕上打印杨辉三角。11 11 2 11 3 3 1。。。。#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <math.h>#include <stdlib.h>#include <string.h>#include <time.h>int main(){ int i = 0; int j =原创 2021-12-13 12:04:28 · 102 阅读 · 0 评论 -
C _2021_10_17 初识C语言
描述一、KiKi学会了printf在屏幕输出信息,他想输出一架小飞机。请帮他编写程序输出这架小飞机。输入描述:无输出描述:#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <math.h>#include <stdlib.h>#include <string.h>#include <time.h>int main(){ printf("原创 2021-12-06 09:51:31 · 268 阅读 · 0 评论 -
C_2021_11_16 初阶指针
一、作业标题使用指针打印数组内容作业内容写一个函数打印arr数组的内容,不使用数组下标,使用指针。arr是一个整形一维数组。#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <math.h>#include <stdlib.h>#include <string.h>#include <time.h>int main(){ int arr[10原创 2021-12-12 20:26:22 · 129 阅读 · 0 评论 -
C_2021_11_14 操作符详解
一、描述KiKi想知道一个整数的奇偶性,请帮他判断。从键盘任意输入一个整数(范围-231~231-1),编程判断它的奇偶性。输入描述:多组输入,每行输入包括一个整数。输出描述:针对每行输入,输出该数是奇数(Odd)还是偶数(Even)。示例1输入:47输出:EvenOddint main(){ int input = 0; while (scanf("%d", &input) != EOF) { if (input % 2 == 0)原创 2021-12-12 11:15:20 · 116 阅读 · 0 评论 -
C_2021_11_11 操作符详解
一、作业标题求两个数二进制中不同位的个数作业内容编程实现:两个int(32位)整数m和n的二进制表达中,有多少个位(bit)不同?输入例子:1999 2299输出例子:7#define _CRT_SECURE_NO_WARNINGS#include <stdio.h>#include <math.h>#include <stdlib.h>#include <string.h>#include <time.h&.原创 2021-12-12 10:46:43 · 109 阅读 · 0 评论 -
C_2021_11_30 作业讲解
一、描述从键盘输入a, b, c的值,编程计算并输出一元二次方程ax2+ bx + c = 0的根,当a = 0时,输出“Not quadratic equation”,当a ≠ 0时,根据△ = b2-4*a*c的三种情况计算并输出方程的根。输入描述:多组输入,一行,包含三个浮点数a, b, c,以一个空格分隔,表示一元二次方程ax2+ bx + c = 0的系数。输出描述:针对每组输入,输出一行,输出一元二次方程ax2+ bx +c = 0的根的情况。如果a = 0...原创 2021-12-15 10:26:20 · 967 阅读 · 0 评论 -
C_2021_11_18 结构体
一、作业标题喝汽水问题作业内容喝汽水,1瓶汽水1元,2个空瓶可以换一瓶汽水,给20元,可以多少汽水(编程实现)int main(){ int i = 20;//一共20元 int count = 20;//先直接买20瓶水 while (i > 1) { if (i % 2 == 0) { count = count + i / 2; i = i / 2; } else { count = count + i / 2; i =原创 2021-12-12 20:47:45 · 246 阅读 · 0 评论