SHOWING THE SECOND LAST ELEMENT OF A LINKED LISTS
Language=C
#include<stdio.h>
#include<stdlib.h>
struct linked_lists
{
int data;
struct linked_lists *next;
};
typedef struct linked_lists node;
void create( node *list );
void show_before_last( node *list );
int main()
{
node *head;
head = ( node* ) malloc( sizeof( node ) );
create( head );
show_before_last( head );
return 0;
}
void create( node *list )
{
char c;
scanf( "%d%c",&list->data,&c );
if(c == '\n')
list->next = NULL;
else
{
list->next = ( node* ) malloc ( sizeof( node ) );
create( list->next );
}
return;
}
void show_before_last( node *list )
{
while( list->next->next )
list = list->next;
printf( "%d\n",list->data );
return;
}
Sunday 14 August 2016
Subscribe to:
Post Comments (Atom)
Kruskal Algorithm
Minimum Cost Spanning Tree By Kruskal Algorithm using priority_queue in c++ #include<bits/stdc++.h> using namespace std; typedef p...
-
Using Divide And Conqure Technique finding maximum and minimum value of an array Language C++ /************ done! ************/ #inc...
-
LINKED LIST
-
CODEFORCES 709A-Juicer Solution #include<iostream> using namespace std ; int main ( ) { int n , b , d ; ...
No comments:
Post a Comment