SCHOOL OF CODE BUILDERS
Learn To CODE. Become A DEVELOPER.
Pages
HOME
DATA STRUCTURES
STRINGS
ARRAYS
MATRIX
BINARY TREES
LINKED LIST
STACK
QUEUE
SORTING
SEARCHING
C
PYTHON
PSEUDOCODE
CONTEST PROBLEMS
ALGORITHMS
PATTERNS
PHP
C PUZZLES
C INTERVIEW QUESTIONS
JAVA
C++
HASHING
RECURSION
BASIC C PROGRAMS
TCS-CODEVITA
FACEBOOK
CONTACT US
Given a list ,for example 1 2 3 4 5 print like 5 4 4 3 3 2 2 1 1 0
Given a list ,for example 1 2 3 4 5 print like 5 4 4 3 3 2 2 1 1 0
#include
#include
struct node { int data; struct node *next; }; struct node* newnode(int data) { struct node *new=(struct node*)malloc(sizeof(struct node)); new->data=data; new->next=NULL; return new; } void insertashead(struct node **head,int data) { struct node *temp=newnode(data); if((*head)==NULL) *head=temp; else { temp->next=(*head); (*head)=temp; } } void printlist(struct node *head) { while(head!=NULL) { printf("%d ",head->data); head=head->next; } } void reverse(struct node *head) { if(head==NULL) return; reverse(head->next); printf("%d ",head->data); head->data=head->data-1; printf("%d ",head->data); } int main(void) { struct node *head=NULL; int n,x,i; scanf("%d",&n); for(i=0;i
PREVIOUS
NEXT
HOME