挽梦君
发表于 2021-1-30 16:25:27
感谢小甲鱼、、、、
邱华琳
发表于 2021-2-21 19:26:03
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
typedef struct Node
{
int value;
struct Node *next;
}Node;
void printList(Node *head)
{
head = head->next;
int i=1;
while(head!=NULL)
{
printf("%d ",head->value);
head = head->next;
}
printf("\n");
}
void makeList(Node **head,int len,int Max)
{
Node *r,*n;
r = *head;
srand((unsigned)time(NULL));
int i=1;
while(i++ <=len)
{
n = (Node*)malloc(sizeof(Node));
n->value = rand()%Max+1;
r->next =n;
n->next = NULL;
r= n;
}
printf("链表创建完毕!\n");
}
void Mid(Node *head)
{
Node *max,*min;
max = head;
min = head;
while(max->next != NULL)
{
if(max->next->next != NULL)
{
max = max->next->next;
min = min->next;
}
}
printf("中间节点的值为:%d\n",min->value);
}
int main()
{
Node *head = (Node *)malloc(sizeof(Node));
printf("1,查看链表\n");
printf("2,创建链表(尾插法)\n");
printf("3,链表长度\n");
printf("4,中间节点值\n");
printf("0,退出\n");
int ch;
int len=20,Max = 100;
while(1)
{
printf("\n请输入编号选择操作(0/1/2/3/4):\n");
scanf("%d",&ch);
switch(ch)
{
case 2:makeList(&head,len,Max);break;
case 1:printList(head);break;
case 3:printf("Length = %d\n",len);break;
case 4:Mid(head);break;
case 0:return;
default:printf("输入有误!请重新输入!");
}
}
return 0;
}
Eugene21
发表于 2021-2-25 22:17:47
鱼币咋获取,回复吗
咔咔Zzy
发表于 2021-9-17 00:08:09
vip 下次一定
lovedboy
发表于 2022-1-26 16:00:30
感谢小甲鱼
SHxhx123
发表于 2022-6-14 21:36:28
感谢小甲鱼
豆腐泡
发表于 2023-3-20 21:40:14
支持小甲鱼
是鱼乐呀哒
发表于 2023-9-26 19:32:36
怎么赚鱼币呀