当前位置:网站首页>Delete the number of a range in the linked list
Delete the number of a range in the linked list
2022-06-13 02:56:00 【Knowing and knowing】
requirement :
Know a linked list , There are 5 Elements , In turn :2,29,41,67,6, It is required to delete more than or equal to in the linked list 20, Less than or equal to 40 Number of numbers , And output the deleted linked list .
Reference code :
#include <stdio.h>
#include <stdlib.h>
struct node{
int data;
struct node *next;
};
struct node* init(struct node* linkList,int arr[],int length){
linkList = NULL;
struct node *p;
int i=0;
printf(" Linked list before deletion :");
while(i<length){
p = (struct node*)malloc(sizeof(struct node));
p ->data = arr[i];
printf("%d,",p->data);
p ->next = linkList;
linkList = p;
i++;
}
printf("\n");
return linkList;
}
struct node* Delete(struct node* Linklist,int min,int max)
{
struct node* head;
head = (struct node*)malloc(sizeof(struct node));
head->next=Linklist;
struct node* tail;
tail = head;
while (head->next)
{
if (head->next->data >=min && head->next->data <= max){
head->next = head->next->next;
}
else{
head = head->next;
}
}
return tail->next;
}
int main()
{
struct node *a,*result;
int arr[]={
2,29,41,67,6};
result=init(a,arr,5);
result=Delete(result,20,40);
printf(" Deleted list :");
for(result; result != NULL; result = result ->next){
printf("%d,",result->data);
}
printf("\n");
system("pause");
return 0;
}
边栏推荐
- . Net compact Framework2.0 wince intelligent device development project experience sharing Net drag space advanced
- For loop instead of while loop - for loop instead of while loop
- . New features in net 6.0 _ What's new in net 6.0
- Ffmpeg principle
- Beginner development process_ Project development FAQs
- PK of dotnet architecture
- HEAP[xxx.exe]: Invalid address specified to RtlValidateHeap( 0xxxxxx, 0x000xx)
- Hash tables: metaphrases
- 专业的数据库管理软件:Valentina Studio Pro for Mac
- Why does it feel that most papers still use RESNET as the backbone network rather than densenet?
猜你喜欢

Linked list: orderly circular linked list

【 enregistrement pytorch】 paramètre et tampon des variables pytorch. Self. Register Buffer (), self. Register Paramètre ()
![[data analysis and visualization] key points of data drawing 8- use of circular bar chart](/img/1f/232f2f0134867eeec3f1cfe005b2b5.jpg)
[data analysis and visualization] key points of data drawing 8- use of circular bar chart
![[thoughts in the essay] mourn for development technology expert Mao Xingyun](/img/6b/d1ef40855fc5ba8275dc624ed61dc2.jpg)
[thoughts in the essay] mourn for development technology expert Mao Xingyun

Vs 2022 new features_ What's new in visual studio2022

Bi modal progressive mask attention for fine graded recognition

Radio design and implementation in IVI system

Data processing in detailed machine learning (II) -- Feature Normalization

Summary of the latest IOS interview questions in June 2020 (answers)

CDN single page reference of indexbar index column in vant framework cannot be displayed normally
随机推荐
Introduction to Sitemap_ Sitemap online generation and sorting
Introduction to facial expression recognition system -- offline environment configuration
Introduction to facial expression recognition system - Technical Paper Edition
Find the number of permutations
OneNote使用指南(一)
Principle and steps of principal component analysis (PCA)
Opencv 9 resize size change rotate rotate blur mean (blur)
Beginner development process_ Project development FAQs
Radio design and implementation in IVI system
How to select fund products? What kind of fund is a good fund?
Hash tables: metaphrases
Modify the color of El input, textarea and El checkbox when they are disabled
Ijkplayer source code - remuxing
[life science] DNA extraction of basic biological experiments
. Net compact Framework2.0 wince intelligent device development project experience sharing Net drag space advanced
Simple use of leaflet - offline map scheme
Ijkplayer source code ---setdatasource
AAR packaging and confusion
Professional database management software: Valentina Studio Pro for Mac
How to manage the IT R & D department?