Compare commits
3
Commits
main
...
c0a432b2e7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c0a432b2e7 | ||
|
|
4d9c36b471 | ||
|
|
9f333aa21c |
Executable
BIN
Binary file not shown.
@@ -0,0 +1,58 @@
|
|||||||
|
#include<stdio.h>
|
||||||
|
#include<stdlib.h>
|
||||||
|
#include "linkedlist.h"
|
||||||
|
|
||||||
|
|
||||||
|
Node *head = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
void insert(int data)
|
||||||
|
{
|
||||||
|
Node *newNode = malloc(sizeof(Node));
|
||||||
|
|
||||||
|
newNode->data = data;
|
||||||
|
newNode->next = head;
|
||||||
|
|
||||||
|
head = newNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void display()
|
||||||
|
{
|
||||||
|
Node *temp=head;
|
||||||
|
|
||||||
|
while(temp!=NULL)
|
||||||
|
{
|
||||||
|
printf("%d ",temp->data);
|
||||||
|
temp=temp->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int search(int value)
|
||||||
|
{
|
||||||
|
Node *temp = head;
|
||||||
|
|
||||||
|
while(temp != NULL)
|
||||||
|
{
|
||||||
|
if(temp->data == value)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
temp = temp->next;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int count()
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
Node *temp = head;
|
||||||
|
|
||||||
|
while(temp != NULL)
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
temp = temp->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
#ifndef LINKEDLIST_H
|
||||||
|
#define LINKEDLIST_H
|
||||||
|
|
||||||
|
typedef struct Node
|
||||||
|
{
|
||||||
|
int data;
|
||||||
|
struct Node *next;
|
||||||
|
|
||||||
|
}Node;
|
||||||
|
|
||||||
|
|
||||||
|
void insert(int data);
|
||||||
|
void display();
|
||||||
|
int search(int value);
|
||||||
|
int count();
|
||||||
|
|
||||||
|
#endif
|
||||||
Reference in New Issue
Block a user