链栈的基本操作 #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
一元多项式的加法 #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;
单循环链表和合并两个单循环链表(尾指针和头指针) #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;
合并两个有序的单链表 不允许额外申请结点空间可将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;.
链表的基本操作 #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;
链表的初始化 查找数据 #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
数据结构顺序表的基本操作,查询、插入、删除 #include<stdio.h>#define MAX 100#define type inttypedef struct{ type elem[MAX]; int last;}Seqlist;void init(Seqlist *L){ L->last = -1;}void input(Seqlist *L){ printf("输入数据 -1结束"); int n, i; i = 0; scanf_s("%d", &n); while(
线性表的插入一个数字 #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
给定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++)
第几天 统计这天是那一年的第几天#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
每个元素循环右移 要求编写程序,将给定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 31 2 34 5 67 8 9 输出2 3 1 5 6 4 8 9 7 #include<stdio.h>#defin
2020-12-21 #include <stdio.h>int main(){ printf("输入一行字符:"); char ch; int i,count=0,word=0; while((ch=getchar())!='') if(ch==' ') word=0; else if(word==0) { word=1; count++;
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[