| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 580 人关注过本帖
标题:[求助]那位帮忙改错啊!
只看楼主 加入收藏
city505
Rank: 1
等 级:新手上路
帖 子:26
专家分:0
注 册:2005-11-5
收藏
 问题点数:0 回复次数:0 
[求助]那位帮忙改错啊!

再下写的一个通讯录:
里面包括插入,删除,输入,查找。帮忙改错。

#include "stdio.h"
#include "stdlib.h"
#include "string.h"
struct date
{
int year;
int month;
int day;
};
struct student
{
char name[20];
long num;
char sex[6];
struct date birthday;
long tel;
long QQ;
struct student *next;
}s[5],*head,*this,*new;
main()
{
void input();
void serch();
void insert();
void del();
int n,i;
printf(" please chose one \n");
printf(" 1 please input student infomation\n");
printf(" 2 serch student infomation\n");
printf(" 3 insert student infomation\n");
printf(" 4 delete student infomation\n");
printf(" 5 exit student system\n");
scanf("%d",&i);
switch(i)
{
case 1: input();break;
case 2: serch();break;
case 3: insert();break;
case 4: del();break;
default:break;
}
}
input(void)
{
char a[20];
int i;
for(i=0;i<5;i++)
{
printf("please student name:");
gets(s[i].name);
printf("please input student num:");
gets(a);s[i].num=atol(a);
printf("please sex:f/m:");
gets(student[i].sex);
printf("please brithday:");
scanf("%d",s[i].brithday.year);
scanf("%d",s[i].brithday.month);
scanf("%d",s[i].brithday.day);
printf("please input tel num:");
gets(a);s[i].tel=atol(a);
printf("please input QQ:");
gets(a);student[i].QQ=atol(a);
}
}
insert()
{
char a[20];
new=(struct student)malloc(sizeof(struct student));
if(head==NUll)
head=new;
else
{
this=head;
while(this->next!=NUll)
this=this->next;
this->next=new;
}
this=new;
printf("input name :");
gets(this->name);
printf("input num:");
gets(this->num);
printf("inpue sex:");
gets(this->sex);
printf("input birthday year:");
scanf("%d",&this->birthday->year);
printf("input brithday month:");
scanf("%d",&this->brithday->month);
printf("input birthday day:");
scanf("%d",&this->birthday->day);
printf("input tel num:");
gets(a);this->tel=atol(a);
printf("input QQ num:");
gets(a);this->QQ=atol(a);
this->next=NULL;
}
serch()
{
char a[20];
long i;
printf("input num:");
gets(a);i=atol(a);
if(head==NULL)
printf("no student:");
else
{
this=head;
while(this->next!=i)
this=this->next;
puts(this->name);
printf("%ld",this->num);
puts(this->sex);
printf("%d %d %d",this->birthday->year,this->birthday->month,this->birthday.day);
printf("%ld",this->tel);
printf("%ld",this->QQ);
}
this=this->next;
}
del()
{
char a[20]
int j;
long i;
gets(a),i=atol(a);
this=head;
if(head!=NULL)
printf("no student");
else
{
for(i=0;i<100;i++)
if(s[i]==i)
s[i-1]->next=s[i+1];
}

}

搜索更多相关主题的帖子: 改错 
2005-12-18 17:00
快速回复:[求助]那位帮忙改错啊!
数据加载中...
 
   



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

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