qsr10250030  
saturn
日历
<2007年1月>
31123456
78910111213
14151617181920
21222324252627
28293031123
45678910
统计
  • 随笔 - 15
  • 文章 - 0
  • 评论 - 6
  • 引用 - 0

导航

常用链接

留言簿(2)

随笔档案(15)

金属网

我的编程

搜索

  •  

最新评论

阅读排行榜

评论排行榜

 
#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<<"请输入学号、姓名:"<<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<<"请输入要删除的编号:"<<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<<"没有找到! "<<endl;
  h1=head;
  if(head!=null)
   do{cout<<h1->num<<" "<<h1->name<<endl;
   h1=h1->next;
   }while(h1!=null);
  end:getch();
  return 0;}
 
posted on 2007-01-12 18:55 快乐蝴蝶飞 阅读(285) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


 
Copyright © 快乐蝴蝶飞 Powered by: 博客园 模板提供:沪江博客