| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 695 人关注过本帖
标题:[求助]不能运行Del 不能删除 卡住了
只看楼主 加入收藏
qiweiwei1986
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2007-6-21
收藏
 问题点数:0 回复次数:0 
[求助]不能运行Del 不能删除 卡住了

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include<iostream.h>

#define NULL 0
#define N 3
typedef struct course
{
char cname[20];//学科名
int score;
}COURSE;
/*定义常数*/
typedef struct student_node /*定义数据结构*/
{
char no[11];//学号

char name[15];
COURSE score[N];
float sum;
float average;
struct student_node *next;
struct student_node *prior;
}STUDENT;
student_node *L;


//void Initlist();
void regist();
void del();

int main()

{
L=(struct student_node*)malloc(sizeof(struct student_node));
L->next=L->prior;
int option;
while(1)
{
cout<<"1.建立(插入)"<<"\n";
cout<<"2.删除记录"<<"\n";
cin>>option;
switch(option)
{
case 1:
regist();
break;
case 2:
del();
break;

}
}
return 0;
}
//////初始化
//void Initlist()
//{
// L=(struct student_node*)malloc(sizeof(struct student_node));
// L->next=L->prior;
//}

/////////建立
void regist()
{
char ch;
student_node *p,*s;
do
{
s=L;
p=(struct student_node*)malloc(sizeof(struct student_node));
cout<<"*********开始建立************"<<"\n";
cout<<"输入学号 ";
cin>>p->no;
cout<<"输入姓名 ";
cin>>p->name;
cout<<"输入学科名 ";
cin>>p->score[0].cname;
cout<<p->score[0].cname<<"成绩 ";
cin>>p->score[0].score;

cout<<"输入学科名 ";
cin>>p->score[1].cname;
cout<<p->score[1].cname<<"成绩 ";
cin>>p->score[1].score;

cout<<"输入学科名 ";
cin>>p->score[2].cname;
cout<<p->score[2].cname<<"成绩 ";
cin>>p->score[2].score;

s->next=p;
p->prior=s;
s=p;

p->next=L;
L->prior=p;
fflush(stdin);
cout<<"是否继续建立(Y\N)"<<"\n";
cin>>ch;
}while(ch=='Y'||ch=='y');
return;
}


////////删除
void del()
{

student_node *p,*q=L;

char no1[11];
cout<<"输出要删除学生的学号";
cin>>no1[11];
while(p)
{
if(!strcmp(p->no,no1))
break;
else
{
q=p;
p=p->next;
}

}
if(!p)
{
cout<<"不存在此学生的信息."<<"\n";
return;
}

cout<<"请问真的要删除该学生的信息吗?(Y/N)"<<"\n";
char ch;
fflush(stdin);
cin>>ch;
if(ch=='y'||ch=='Y')
{
q->next=p;
p->next->prior=q;
free(p);
}
}

调试没错误 但运行是不能删除

搜索更多相关主题的帖子: Del 运行 删除 
2007-06-21 10:54
快速回复:[求助]不能运行Del 不能删除 卡住了
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019955 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved