c语言编程,求帮助!!!

.学生学籍管理(1) 能建立新数据记录,存放学生信息及学籍
(2) 能追加新记录
(3) 能修改已有记录
(4) 能删除已有记录
(5) 能查询部分记录
(6) 能排序记录

给你个社团管理的可以吗?要考试了的确没有时间,自己改下。

#include<stdio.h>
#include<stdlib.h>
struct comunity
{
char name[20];
char major[20];
char studynum[20];
char phonenum[20];
int length;
comunity *next;
};
comunity *head=(comunity *)malloc(sizeof(comunity));

void initial(comunity *head)//初始化
{
/*head->next=NULL;
(head->studynum)[0]=NULL;
(head->major)[0]=NULL;
(head->name)[0]=NULL;
(head->phonenum)[0] =NULL;*/
head->next =NULL;
}

void creat()//创建或者添加
{
char ch1;
//char ch2;
if((head->next)==NULL){

struct comunity *q;

q=(comunity *)malloc(sizeof(comunity));

initial(q);
q=head;
do{
printf("是否继续创建,'y' or 'n'\n");
getchar();
scanf("%c",&ch1);
if(ch1=='y'){
comunity *temp=(comunity *)malloc(sizeof(comunity));
printf("请你依次输入姓名 专业 学号 电话号码\n");
scanf("%s%s%s%s",temp->name,temp->major,temp->studynum ,temp->phonenum );
q->next=temp;
q=temp ;

}
else
break;
}
while(1);
q->next =NULL;

//free(q);
}
else{
printf("该数据内容已被初始化\n");
//while(1){
//printf("增加的为:姓名 专业 学号 电话号码\n");
//comunity *temp=(comunity *)malloc(sizeof(comunity));
//q=temp;
//scanf("%s%s%s%s",temp->name,temp->major,temp->studynum ,temp->phonenum);
//printf("是否继续,'y' or 'n'");
//scanf("%c",&ch2);
//if(ch2=='n')
// break;
// }
comunity *p;
p=head;
while(p->next!=NULL)
{
p=p->next ;

}
//while(1){
printf("增加的为:姓名 专业 学号 电话号码\n");
comunity *corss=(comunity *)malloc(sizeof(comunity));
scanf("%s%s%s%s",corss->name,corss->major,corss->studynum ,corss->phonenum);
p->next=corss;
p->next->next =NULL;
//}
}

}
void showall()//显示社团里的人得所有信息
{
if(head->next ==NULL){
printf("没有输入数据\n");
}
else {
comunity *q;//=(comunity *)malloc(sizeof(comunity));
//initial(q);
q=head ;
while( q!=NULL&&(q->next)!=NULL)
{

printf("%s %s %s %s",q->next->name ,q->next->major,q->next->studynum,q->next->phonenum);
printf("\n");
q=q->next ;
}
}

}
/*int compare(char a[],char b[])//判断两个字符串是否相等
{
int i;
for(i=0,a[i]!='\n';i++)
if(a[i]=b[i])
re
}*/

int checkeq(char a[],char b[])//判断字符串是否相等
{
int i;
for(i=0;a[i]!=NULL;i++)
{
if(a[i]!=b[i])
return 0;
}
if(b[i]!=NULL)
return 0;

return 1;
}
/*
bool checkeq(char a[],char b[])
{
int i;
for( i=0;b[i]!='\0';i++){
if(a[i]!=b[i]){
return false;
}
}
if(a[i]!='\0'){
return false;
}
return true;
}
*/

void find()//查找社团中是否存在此人
{
char finder[20];
comunity * p;

if(head->next==NULL)
printf("还没有输入数据\n");
else{

p=head;
printf("请你输入你要查找的数据\n");
getchar();
scanf("%s",finder);

while(checkeq(p->name,finder)==0 && p->next!=NULL)
{
p=p->next;
}
if(checkeq(p->name,finder)){

printf("找到了这个人%s %s %s %s\n",p->name,p->major,p->studynum,p->phonenum);

//else
// printf("找到了这个人%s %s %s %s\n",p->name,p->major,p->studynum,p->phonenum");
}
else
printf("社团中没有这个人\n");
}

}

void disappear()//删除成员
{
comunity *p,*q;

if(head->next==NULL)
printf("还没有输入数据\n");
else{
char finder[20];
p=head;
printf("请你输入你要删除的成员\n");
getchar();
scanf("%s",finder);

while(checkeq(p->name,finder)==0&&(p->next)!=NULL)
{
q=p;
p=p->next;
}
if(p==NULL){
printf("社团中没有这个人\n");
}
else{
q->next=p->next ;
free(p);
printf("删除完成\n");
}

}

}

void change()
{
comunity *p;
char changer[20];
if(head->next==NULL)
printf("还没有输入数据\n");
printf("请你输入你要更改的数据\n");
scanf("%s",changer);
p=head;
while(checkeq(p->name,changer)==0 && p->next!=NULL)
{
p=p->next;
}
if(checkeq(p->name,changer)==1 )
{
printf("找到了这个人%s %s %s %s\n",p->name,p->major,p->studynum,p->phonenum);
printf("请你将更改好了的数据输入:姓名 专业 学号 电话号码\n");
scanf("%s%s%s%s",p->name,p->major,p->studynum ,p->phonenum );
printf("修改完成\n");
}
else
printf("你要修改的数据无法找到\n");
}

void main()
{
initial(head);
int ch;
do
{
printf("这是高校社团管理系统\n");
printf("有以下几个功能,供你选择:1:输入社团信息;2:删除社团成员;3:查找社团成员;4:更改社团成员信息;5:输出社团信息;0:退出\n");
printf("请你选择:");
scanf("%d",&ch);
switch(ch)
{
case 1:creat(); break;
case 2:disappear();break;
case 3:find(); break;
case 4:change();break;
case 0: exit(0);
case 5:showall();break;
default: printf("输入错误,请你从新输入\n");
}

}
while(1);
}
温馨提示:内容为网友见解,仅供参考
第1个回答  2013-06-23
写一个student类,然后把类实体放到vector里。

能追加新记录,就是向vector里添加类实体。

能修改已有记录,就是在vector里查找实体,然后修改

能删除已有记录,就是删除vector里的某个实体

查询部分记录,就是根据学生的学号或者姓名在vector里查找实体

排序记录,调用sort方法即可。追问

求具体程序!

能具体点吗

追答

这个就是思路,以后你工作了,如果不知道怎么写代码,你的leader就会给你这样的思路,然后照着这个思路写,写起来比较麻烦,没有这个时间。

本回答被网友采纳
相似回答