Linked list-deletion of data in a 1 linked list

Source: Internet
Author: User

http://acm.nefu.edu.cn/JudgeOnline/problemShow.php?problem_id=1068

This is a code that deletes a specific character in a linked list, and learns the first time a linked list has been written.

1#include <iostream>2#include <stdio.h>3#include <cstring>4#include <algorithm>5#include <math.h>6 using namespacestd;7 structSA8 {9     Charch;Ten     structSA *Next; One }; A intShow (SA *t)//Print linked list - { -      while(t->next!=NULL) the     { -cout<<t->ch<<Endl; -T=t->Next; -     } +     return  0; - } + intDel (SA *t,CharData//clears the specified single character A { at      while(t->next!=NULL) -     { -         if(t->next->ch==data) -         { -T->next=t->next->Next; -              Break; in         } -T=t->Next; to     } +     return 0; - } the intMain () * { $SA *p,*Q;Panax Notoginseng     Chardata; -     intN; the      while(cin>>N) +     { Ap=q= (SA *)malloc(sizeof(SA));//Request a Space the          for(intI=0; i<n;i++) +         { -cin>>p->ch;//Assign Value $p->next= (SA *)malloc(sizeof(SA));//to link different spaces together $P=p->Next; -         } -p->next=null;//The sign of the end of the space chain theCin>>data; - del (q,data);Wuyi Show (q); the     } -     return 0; Wu}
View Code

Linked list-deletion of data in a 1 linked list

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.