| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1543 人关注过本帖
标题:[已解决!谢谢]各位高手朋友:这链表怎么修改啊?
只看楼主 加入收藏
小小
Rank: 1
等 级:新手上路
威 望:1
帖 子:219
专家分:0
注 册:2004-5-31
收藏
 问题点数:0 回复次数:9 
[已解决!谢谢]各位高手朋友:这链表怎么修改啊?

#include"stdlib.h" #include"stdio.h"

struct stud {char name[20]; long num;

float score; float score_1; float score_2; float score_3; struct stud *next; }; struct stud *head, *this, *new; main() { char ch; int flag=1; head=NULL; printf("***************************************************************\n"); printf("| -> welcome to use ! <- |\n"); printf("| |\n"); printf("| All rights resevered 03101 Huang wenmin |\n"); printf("********* Http://elian.hbisp.com **********\n");

while(flag) {

printf(" ---------------------------------------------------------------\n"); printf(" 1.Add new information. 2.List all information. \n"); printf(" 3.Delete a student's record . 4.Quit. \n"); printf("---------------------------------------------------------------\n"); printf("Type the fist letter of the item to choose.And the press Enter.\n"); ch=getchar();getchar(); switch(ch) { case'a': case'A':new_record();break; case'l': case'L':listall();break; case'd': case'D':del_record();break; case'q': case'Q':exit(0);break; default:flag=0; } } }

new_record(void) /*输入信息*/ { char numstr[20]; new=(struct stud *) malloc (sizeof (struct stud)); if(head==NULL) head=new; else {this=head; while (this->next!=NULL) this=this->next; this->next=new; } this=new; printf("\nenter name:"); gets(this->name); printf("\nenter number:"); gets(numstr); this->num=atol(numstr); printf("\nEnter Enlish score:"); gets(numstr); this->score=atof(numstr); printf("\nEnter Chinese score:"); gets(numstr); this->score_1=atof(numstr); printf("\nEnter Computer score:"); gets(numstr); this->score_2=atof(numstr); printf("\nEnter Mathimatics score:"); gets(numstr); this->score_3=atof(numstr); this->next=NULL;

}

listall(void) /*列出已记录的信息*/ {int i=0; if(head==NULL) {printf("\I am sorry,but the list is nempty list.:P \n\n\n");

return; } this=head; do{ printf("\nrecord number %d\n",++i); printf("name:%s\n",this->name); printf("num:%ld\n",this->num); printf("Enlish score:%6.2f\n",this->score); printf("Chinese score:%6.2f\n",this->score_1); printf("Computer score:%6.2f\n",this->score_2); printf("Mathimatics score:%6.2f\n",this->score_3); this=this->next; }while(this!=NULL); } del_record(void) /*删除信息*/ { if(head==NULL) printf("no found!\n\n\n"); /*如果链表头为空则返回*/

else { char *p,*p1;/*一个指向输入的学生名,另一个指向结构中的学生名*/ int s;/*比较字符结果,相等为0,不等为其它数*/ printf("enter name to del:\n"); scanf("%s",p); this=head; new=NULL; do { p1=this->name; if( !( s=strcmp(p,p1) ) ) /*如果比较相等,则跳出循环*/ break; new=this;/*保存上一个结构指针*/ this=this->next;/*指向下一个结构*/ } while ( NULL != this->next ); if( !(new)) head=this->next;/*如果头结点为要删除的学生,将下一个结点作为头结点*/ else if( !(this->next=NULL) ) /*如果是最后一个结点为要删除的学生*/ new->next=NULL; else new=this->next;/*将上一个结点指为本节点的下一个结点*/ printf("deled successfully!\n\n\n"); } } 上周在这里求这个程序:

用链表实现学生成绩管理系统

要求:1。能录入学生各科成绩;

2。能查询学生各科成绩;

3。能修改学生各科成绩;

4。删除学生成绩;

5。退出程序。

jiely的回复是:

可以给你个参考的程序,呵呵~,不过要帮你写,可能大家都没有时间吧~~~~~,大家可以帮你修改程序,但不是代劳~

那现在偶完成了些,可有个问题需要修改,就是在运行完删除命令后,再运行其他,怎么就马上退出程序了啊?帮忙修改一下?

修改个人成绩的函数怎么写啊,我写不来,帮一下可以吗

[此贴子已经被作者于2004-06-10 23:14:22编辑过]

搜索更多相关主题的帖子: 链表 float score stud 
2004-06-10 13:45
小小
Rank: 1
等 级:新手上路
威 望:1
帖 子:219
专家分:0
注 册:2004-5-31
收藏
得分:0 

救救我啊

明天就要交了~~~

我做到这里实在不会了


有一天咖啡的舞者 £
2004-06-10 18:49
流星雨
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:JAVA风暴
等 级:版主
威 望:43
帖 子:1854
专家分:1868
注 册:2004-5-30
收藏
得分:0 
按学生代号查找,若查找到对应记录,则输入其修正量,将它累加后,再将该记录写回原有位置,若是没有查找到,则返回出错,思路许是如此,但程序太长,我虽可写出,但不能保证100%全对,有时间我会给予你一个参考程序,不过最好还是有高手能够愿意帮助你,那样,你就万无一失了!

感谢你们带我找到星空下美丽神话,无论经历多少苦痛也不放弃的梦;插上希望翅膀乘风我和你们飞翔,飞过海天尽头携手把梦想实现.....
2004-06-10 19:40
小小
Rank: 1
等 级:新手上路
威 望:1
帖 子:219
专家分:0
注 册:2004-5-31
收藏
得分:0 

谢谢流星雨小姐~~~

我初学,还没达到看懂上面思路的水平,可怜啊~~


有一天咖啡的舞者 £
2004-06-10 20:10
流星雨
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:JAVA风暴
等 级:版主
威 望:43
帖 子:1854
专家分:1868
注 册:2004-5-30
收藏
得分:0 

回答你的问题“修改个人成绩的函数”!

其实就是修改线性表中给定值的元素,

Update(list&L,const ElemType& item)

{

for(int i=0;i<L,size;i++)

if(L.lish[i]==item){

returm item

}

}

做个参考吧,希望能有更多朋友帮助你,最好是有高手哦!


感谢你们带我找到星空下美丽神话,无论经历多少苦痛也不放弃的梦;插上希望翅膀乘风我和你们飞翔,飞过海天尽头携手把梦想实现.....
2004-06-10 20:27
zff_ff
Rank: 1
等 级:新手上路
帖 子:147
专家分:0
注 册:2004-5-12
收藏
得分:0 

change_record(void)

{

long no;

printf("请输入学号);

stud *newnode;

newnode=(struct stud *) malloc (sizeof (struct stud));

newnode=head;

while ( newnode->next==NULL ){

if(newnode->num==no)

black;

else

newnode=newnode->next;}

if(newnode->num==no){

prinf("请输入数据");

gets(newnode->score);

gets(newnode->score_1);

gets(newnode->sscore_2);

gets(newnode->score_3);}

else

printf("不存在该生")

}

最近忙着考试,好久没来了

这是我刚才粗粗写了一下,估计错了还不少

你自己调试吧,我这里用的是vc没法帮你调试

最后给你一点建议,不要用new和this作变量


偶是一只想要飞却忘了咋飞的菜鸟
2004-06-10 20:54
小小
Rank: 1
等 级:新手上路
威 望:1
帖 子:219
专家分:0
注 册:2004-5-31
收藏
得分:0 

好的,倒霉鬼3是好同志啊

哈哈

我在调试


有一天咖啡的舞者 £
2004-06-10 21:27
小小
Rank: 1
等 级:新手上路
威 望:1
帖 子:219
专家分:0
注 册:2004-5-31
收藏
得分:0 
调试结果

倒霉鬼3,这样怎么修改了

好同志啊


有一天咖啡的舞者 £
2004-06-10 21:49
小小
Rank: 1
等 级:新手上路
威 望:1
帖 子:219
专家分:0
注 册:2004-5-31
收藏
得分:0 

那个black是改成break;

就是那几个

pointer required on left side of ->^^

怎么改


有一天咖啡的舞者 £
2004-06-10 21:52
小小
Rank: 1
等 级:新手上路
威 望:1
帖 子:219
专家分:0
注 册:2004-5-31
收藏
得分:0 

这个问题解决了,感谢各位

特别感谢 zff-ff 干杯!


有一天咖啡的舞者 £
2004-06-10 23:13
快速回复:[已解决!谢谢]各位高手朋友:这链表怎么修改啊?
数据加载中...
 
   



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

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