qsr10250030 |
|
|||
saturn |
日歷
統(tǒng)計(jì)
導(dǎo)航常用鏈接留言簿(2)隨筆檔案(15)金屬網(wǎng)我的編程
搜索最新評(píng)論
閱讀排行榜評(píng)論排行榜 |
#include<iostream>
#include<conio.h> #include<fstream> #include<sstream> #define null 0 using namespace std; int main(){ struct stu{ long num; string name; stu *next;}; struct stu *head,*h1,*h2; h1=h2=new stu; cout<<"請(qǐng)輸入學(xué)號(hào)、姓名:"<<endl; cin>>h1->num>>h1->name; head=null; int n=0; while(h1->num!=0){ ?? n=n+1; ?? if(n==1)head=h1; ?? else h2->next=h1; ?? h2=h1; ?? h1=new stu; ?? cin>>h1->num>>h1->name;?? ? } ? h2->next=null; ? stu p; ? cout<<"請(qǐng)輸入要?jiǎng)h除的編號(hào):"<<endl; ? cin>>p.num; ? if(head==null){cout<<"鏈表是空的!";goto end;} ? h1=head; ? while(p.num!=h1->num&&h1->next!=null){ ???? h2=h1;h1=h1->next;} ???? if(p.num=h1->num){ ???? if(h1==head)head=h1->next; ???? else h2->next=h1->next;} ???? else cout<<"沒(méi)有找到! "<<endl; ? h1=head; ? if(head!=null) ?? do{cout<<h1->num<<" "<<h1->name<<endl; ?? h1=h1->next; ?? }while(h1!=null); ? end:getch(); ? return 0;} ?
|
![]() |
|
Copyright © 快樂(lè)蝴蝶飛 | Powered by: 博客園 模板提供:滬江博客 |