- 博客(23)
- 问答 (3)
- 收藏
- 关注
原创 链栈的基本操作
#include<iostream> using namespace std; typedef struct Node{ int data; struct Node *next; }LinkstackNode, *Linkstack; void Init(LinkstackNode *S) { S = new LinkstackNode; S->next = NULL; } bool Push(Linkstack S, int x) {//头插法 LinkstackNode *t
2021-04-22 16:29:56
90
原创 一元多项式的加法
#include<iostream> using namespace std; typedef struct Polynode{ int coef; int exp; struct Polynode *next; }Polynode, *Polylist; Polylist create() { Polynode *s, *rear, *head; head = (Polynode*)malloc(sizeof(Polynode)); rear = head; int a, b;
2021-04-14 21:53:30
103
原创 单循环链表和合并两个单循环链表(尾指针和头指针)
#include<iostream> using namespace std; typedef struct circular{ int data; struct circular *next, *rear; }Circular, *Linklist; void initclist(Linklist *CL) { *CL = new Circular; (*CL)->next = NULL; } void inpclist(Linklist CL) { Circular *s;
2021-04-13 20:00:30
702
原创 合并两个有序的单链表
不允许额外申请结点空间 可将LC = LA #include<iostream> using namespace std; typedef struct Node { int data; struct Node *next; }Node, *Linklist; void Init(Linklist *L) { *L = new Node; (*L)->next = NULL; } void fromend(Linklist L) { Node *r, *s; int a; .
2021-04-09 17:28:24
108
原创 链表的基本操作
#include<iostream> using namespace std; typedef struct Node { int data; struct Node *next; }Node, *Linklist; void Initlist(Linklist *L) { *L = (Linklist)malloc(sizeof(Node)); (*L)->next = NULL; } void fromhead(Linklist L) { Node *s; int a;
2021-04-07 12:21:22
75
原创 链表的初始化 查找数据
#include<iostream> using namespace std; typedef struct Node { int data; struct Node *next; }Node, *Linklist; void Initlist(Linklist *L) { *L = (Linklist)malloc(sizeof(Node));//*L为头结点,L为头指针 (*L)->next = NULL; } void fromhead(Linklist L) { Nod
2021-04-06 21:45:37
101
原创 数据结构顺序表的基本操作,查询、插入、删除
#include<stdio.h> #define MAX 100 #define type int typedef struct { type elem[MAX]; int last; }Seqlist; void init(Seqlist *L) { L->last = -1; } void input(Seqlist *L) { printf("输入数据 -1结束\n"); int n, i; i = 0; scanf_s("%d", &n); while(
2021-03-31 15:39:50
137
原创 线性表的插入一个数字
#include<stdio.h> #define MAXSIZE 100 #define type int typedef struct { type elem[MAXSIZE]; int last; }Seqlist; void inilist(Seqlist *L) { L->last = -1;//输入-1停止 } void inplist(Seqlist *L) { int i = 0, n; printf("输入数据,-1结束:"); scanf("%d", &a
2021-03-17 20:04:08
438
原创 给定n,c语言输出菱形
//包含标准输入输出函数 #include <stdio.h> //定义main函数 int main() { //请在此添加‘输出菱形’的代码 /*****************Begin******************/ int i, j, k, a; scanf("%d", &a); for(i = 1;i <= a;i++) { for(j = 1; j <= a - i; j++)
2021-02-04 14:06:18
818
原创 第几天
统计这天是那一年的第几天 #include<stdio.h> int f(int year) { return (year % 4 == 0 && year % 100 != 0) || year % 400 == 0; } int main() { int year, month, day, flag = 0, sum = 0; scanf("%d/%d/%d", &year, &month, &day); flag = f(year); s
2020-12-22 19:40:23
83
原创 每个元素循环右移
要求编写程序,将给定n×n方阵中的每个元素循环向右移m个位置,即将第0、1、⋯、n−1列变换为第n−m、n−m+1、⋯、n−1、0、1、⋯、n−m−1列 输入第一行给出两个正整数m和n(1≤n≤6)。接下来一共n行,每行n个整数,表示一个n阶的方阵。 输出格式: 按照输入格式输出移动后的方阵:即输出n行,每行n个整数,每个整数后输出一个空格。 输入 2 3 1 2 3 4 5 6 7 8 9 输出 2 3 1 5 6 4 8 9 7 #include<stdio.h> #defin
2020-12-22 15:02:27
252
原创 2020-12-21
#include <stdio.h> int main() { printf("输入一行字符:\n"); char ch; int i,count=0,word=0; while((ch=getchar())!='\n') if(ch==' ') word=0; else if(word==0) { word=1; count++;
2020-12-21 23:42:18
98
原创 2020-12-21
寻找一维数组第二大的数据 #include<stdio.h> int main() { int a[10] = {1412, 112, 34, 51, 17, 28, 10, 42, 131,3242}, i, max1, max2; max1 = a[0]; max2 = a[0]; for(i = 1; i < 10; i++) if(max1 < a[i]) max1 = a[i]; for(i = 1; i < 10; i++) { if(a[
2020-12-21 23:33:13
92
原创 找出不是两个数组共有的元素
10 3 -5 2 8 0 3 5 -15 9 100 11 6 4 8 2 6 -5 9 0 100 8 1 #include<stdio.h> int main() { int a[20], b[20], c[20]; int m, n, i, j, k=0; scanf("%d", &m); for(i = 0; i < m; i++) scanf("%d", &a[i]); scanf("%d", &n); for(i = 0; i <
2020-12-18 15:07:02
1029
原创 2020-11-18
杨辉三角 #include<stdio.h> #define N 10 int main() { int a[N][N], i, j; for(i = 0; i < N; i++) for(j = 0; j <= i; j++) if(j == 0 || i == j ) a[i][j] = 1; else a[i][j] = a[i - 1][j - 1] + a[i - 1][j]; for(i = 0; i < N; i++) { fo
2020-11-18 11:07:10
83
原创 冒泡排序与选择排序
#include<stdio.h> #define N 10 int main() { int i, j, temp, a[N] = {13, 42, 5, 21, 254, 56, 85, 12, 76, 100}; printf("排序之前:\n"); for(i = 0; i < N; i++) printf("%d ", a[i]); printf("\n"); for(i = 1; i <= N - i; i++) for(j = 0; j < N -
2020-11-18 00:48:51
212
原创 一个数插入有序数组中
#include<stdio.h> int main() { int a[9] ={1, 2, 3, 3, 5, 6, 7, 8}, i, j, t; scanf("%d", &t); for(i = 0; i < 9; i++) { if(t < a[i]) break; } for(j = 8; j > i; j--) a[j] = a[j - 1]; a[i] = t; for(i = 0; i < 9; i++)
2020-11-17 22:57:53
116
原创 快捷键
快捷键的 我 Ctrl+J或者 Ctrl+Space 或者 Alt+Right ------自动补全或者是提示(Ctrl+Space因为被中文输入法抢占,替代的快捷键Alt+Right Shitf+Delete (Ctrl+L)-----删除整行代码(我认为很有用的) Shitf+Home -------选中光标到改行的第一个字母 Shitf+End -------选中光标到改行的最后一个字母 Ctrl+Shitf+End -------选择至文档末尾 C
2020-11-17 20:44:01
496
2
空空如也
c++类的定义与声明 运算符重载
2021-06-22
c++继承,给子类写构造函数,会报父类无默认构造函数,这个对子类写构造函数有啥影响啊
2021-06-17
TA创建的收藏夹 TA关注的收藏夹
TA关注的人