Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - #include <stdio.h>
 - #include <stdlib.h>
 - struct stack {
 - int number,data;
 - struct stack *next;
 - };
 - struct stack *create(struct stack *, int, int);
 - void del(struct stack** ,int);
 - void print(struct stack *p);
 - int main() {
 - int i, n, nd;
 - struct stack *head;
 - head = NULL;
 - scanf("%d", &n);
 - for (i=0; i <= n; i++) {
 - head = create(head,i,i+1);
 - printf("%d)%d\n", i+1,head->data);
 - }
 - printf("\ncacuyu ctrocu udalit?");
 - scanf("%d", &nd);
 - del(&head, nd);
 - print(head);
 - free(head);
 - }
 - struct stack *create(struct stack *head, int x, int num) {
 - struct stack *element;
 - element = (struct stack *)malloc(sizeof(struct stack));
 - element->next = head;
 - element->data = x;
 - element->number = num;
 - return element;
 - }
 - void print(struct stack *p){
 - while (p != NULL) {
 - printf("%d-->", p->data);
 - p = p->next;
 - }
 - }
 - void del(struct stack** p,int n){
 - if ((*p)->number == n) {
 - struct stack* t = *p;
 - *p = (*p)->next;
 - free(t);
 - return;
 - }
 - else {
 - del(&(*p)->next,n);
 - }
 - }
 
                    Add Comment                
                
                        Please, Sign In to add comment