程序设计综合实训——高校教师信息管理系统

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
这题没的说,直接写,我写了三种,后两种是排序不同

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char b[30],d[20];
int l;
typedef struct S{
    int num;
    char name[30];
    char title[20];
    char sex[30];
    char kcmc1[30];
    char stage1[30];
    char nature1[30];
    char jxxg1[20];
    char kcmc2[30];
    char stage2[30];
    char nature2[30];
    char jxxg2[30];
    int zhpf;
    int mak;
}s;
s a[202];
void input()
{
   scanf("%ld%s%s%s%s%s%s%s%s%s%s%s%d",&a[l].num,&a[l].name,&a[l].title,&a[l].sex,&a[l].kcmc1,&a[l].stage1,&a[l].nature1,&a[l].jxxg1,a[l].kcmc2,&a[l].stage2,&a[l].nature2,&a[l].jxxg2,&a[l].zhpf);
   a[l].mak=1;l++;
   return ;
};
void display(int i)
{
    printf("%ld %s %s %s %s %s %s %s %s %s %s %s %d\n",a[i].num,a[i].name,a[i].title,a[i].sex,a[i].kcmc1,a[i].stage1,a[i].nature1,a[i].jxxg1,a[i].kcmc2,a[i].stage2,a[i].nature2,a[i].jxxg2,a[i].zhpf);

};
void search1()
{    int i,o=0;
    scanf("%s",&d);
    for(i=0;i<l;i++)
    {
        if(strcmp(a[i].name,d)==0||strcmp(a[i].kcmc1,d)==0||strcmp(a[i].kcmc2,d)==0)
           {o=1;printf("%ld %s %s %s %s %s %s %s %s %s %s %s %d\n",a[i].num,a[i].name,a[i].title,a[i].sex,&a[i].kcmc1,a[i].stage1,a[i].nature1,a[i].jxxg1,a[i].kcmc2,a[i].stage2,a[i].nature2,a[i].jxxg2,a[i].zhpf);}
    }
    if(o==0)
        printf("NO match!\n");
    for(i=0;i<20;i++)
        d[i]=0;
};
void sort1(int c)
{   int i,j,k;
    if(c==1)
    for(i=0;i<=l-2;i++)
		{  k=i;
		for(j=i+1;j<=l-1;j++)
			if(a[j].zhpf>a[k].zhpf)
				k=j;
			a[200]=a[i];a[i]=a[k];a[k]=a[200];
		}
    else if(c==0)
        for(i=0;i<=l-2;i++)
		{  k=i;
		for(j=i+1;j<=l-1;j++)
			if(a[j].num>a[k].num)
				k=j;
			a[200]=a[i];a[i]=a[k];a[k]=a[200];
		}
    return ;
};
void insert1()
{
    
    scanf("%d%s%s%s%s%s%s%s%s%s%s%s%d",&a[l].num,&a[l].name,&a[l].title,&a[l].sex,&a[l].kcmc1,&a[l].stage1,&a[l].nature1,&a[l].jxxg1,a[l].kcmc2,&a[l].stage2,&a[l].nature2,&a[l].jxxg2,&a[l].zhpf);
    a[l].mak=1;
    l++;
    return ;
};
void change(int c)
{   int i;
    for(i=0;i<l;i++)
    {
        if(a[i].mak==0)
            continue;
        if(a[i].num==c)
        {
            scanf("%d%s%s%s%s%s%s%s%s%s%s%s%d",&a[i].num,&a[i].name,&a[i].title,&a[i].sex,&a[i].kcmc1,&a[i].stage1,&a[i].nature1,&a[i].jxxg1,a[i].kcmc2,&a[i].stage2,&a[i].nature2,&a[i].jxxg2,&a[i].zhpf);
            a[i].mak=1;
            break;
        }
    }return ;
};
void delete1()
{
    int i;
    for(i=0;i<l;i++)
    {
        if(strcmp(a[i].name,d)==0)
            {a[i].mak=0;
        break;}
    }
}
int main()
{    int c,i;
    while(scanf("%s",&b))
    {   getchar();
        if(strcmp(b,"input")==0)
        {
            scanf("%d",&c);
            for(i=0;i<c;i++)
            {
                input();
            }
        }
        else if(strcmp(b,"display")==0)
        {   for(i=0;i<l;i++)
        { if(a[i].mak==1)
           display(i);
        }
        }
        else if(strcmp(b,"search")==0)
        {
            search1();
        }
        else if(strcmp(b,"sort")==0)
        {    scanf("%d",&c);
            sort1(c);
        }
        else if(strcmp(b,"insert")==0)
        {
            insert1();
        }
        else if(strcmp(b,"change")==0)
        {  scanf("%d",&c);
            change(c);
        }
        else if(strcmp(b,"delete")==0)
        {
            scanf("%s",&d);
            delete1();
        }
        else if(strcmp(b,"quit")==0)
            break;

    }return 0;
}

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char b[30],d[20];
int l;
struct S{
    int num;
    char name[30];
    char title[20];
    char sex[30];
    char kcmc1[30];
    char stage1[30];
    char nature1[30];
    char jxxg1[20];
    char kcmc2[30];
    char stage2[30];
    char nature2[30];
    char jxxg2[30];
    int zhpf;
    int mak;
}a[201];
struct ST
{
    S data;
    struct ST *hed;
    struct ST *next;
};
struct ST *createNullList()
{
    struct ST *head;
    head=(struct ST*)malloc(sizeof(struct ST));
    if(head!=NULL)
	{head->next=NULL;head->hed=NULL;}
    return head;
};
struct ST *Head=createNullList();
void connect(struct ST*node)
{
    struct ST* p;
    p=Head;
    while(p->next!=NULL)
        p=p->next;
    p->next=node;
	node->hed=p;

};
void deleteList(struct ST* node)
{
    struct ST* p;
    p=Head;
    node->next->hed=node->hed;
    node->hed->next=node->next;
    while(p==node)
    {
        p=p->hed;
    }
};
int isNullList(struct ST* head)
{
    return head->next==NULL;
};
int getlength(struct ST*Head)
{
    int sum=0;
    struct ST * p;
    p=Head;
    p=p->next;
    while(p!=NULL)
    {
        sum++;
        p=p->next;
    }return sum;
}
void input()
{  S s;
   scanf("%d%s%s%s%s%s%s%s%s%s%s%s%d",&s.num,&s.name,&s.title,&s.sex,&s.kcmc1,&s.stage1,&s.nature1,&s.jxxg1,s.kcmc2,&s.stage2,&s.nature2,&s.jxxg2,&s.zhpf);
   struct ST* node=createNullList();
   node->data=s;
   connect(node);
};
void display()
{   struct ST * p;
    p=Head;
    p=p->next;
    while(p!=NULL)
    {printf("%ld %s %s %s %s %s %s %s %s %s %s %s %d\n",p->data.num,p->data.name,p->data.title,p->data.sex,p->data.kcmc1,p->data.stage1,p->data.nature1,p->data.jxxg1,p->data.kcmc2,p->data.stage2,p->data.nature2,p->data.jxxg2,p->data.zhpf);
      p=p->next;
    }
};
void search1()
{    int i,o=0;
    scanf("%s",&d);
    struct ST * p;
    p=Head;
    p=p->next;
    while(p!=NULL)
        {if(strcmp(p->data.name,d)==0||strcmp(p->data.kcmc1,d)==0||strcmp(p->data.kcmc2,d)==0)
           {o=1;printf("%ld %s %s %s %s %s %s %s %s %s %s %s %d\n",p->data.num,p->data.name,p->data.title,p->data.sex,p->data.kcmc1,p->data.stage1,p->data.nature1,p->data.jxxg1,p->data.kcmc2,p->data.stage2,p->data.nature2,p->data.jxxg2,p->data.zhpf);

           } p=p->next;
        }
    if(o==0)
        printf("NO match!\n");
    for(i=0;i<20;i++)
        d[i]=0;
};
void sort1(int c)
{
    int i,j,k;
    struct ST * p1,*p2;
    p1=Head;
    p1=p1->next;
    l=getlength(p1)+1;
    struct ST * p;
    p=Head;
    p=p->next;
    for(i=0;i<l;i++)
    {a[i]=p->data;
     p=p->next;}

    if(c==1)
    for(i=0;i<=l-2;i++)
		{  k=i;
		for(j=i+1;j<=l-1;j++)
			if(a[j].zhpf>a[k].zhpf)
				k=j;
			a[200]=a[i];a[i]=a[k];a[k]=a[200];
		}
    else if(c==0)
        for(i=0;i<=l-2;i++)
		{  k=i;
		for(j=i+1;j<=l-1;j++)
			if(a[j].num>a[k].num)
				k=j;
			a[200]=a[i];a[i]=a[k];a[k]=a[200];
		}
		p2=Head;
		p2=p2->next;
		for(i=0;i<l;i++)
    {p2->data=a[i];
     p2=p2->next;}
    return ;
};
void insert1()
{

   S s;
   scanf("%d%s%s%s%s%s%s%s%s%s%s%s%d",&s.num,&s.name,&s.title,&s.sex,&s.kcmc1,&s.stage1,&s.nature1,&s.jxxg1,s.kcmc2,&s.stage2,&s.nature2,&s.jxxg2,&s.zhpf);
   struct ST* node=createNullList();
   node->data=s;
   connect(node);
    return ;
};
void change(int c)
{   int i;S s;
    struct ST * p;
    p=Head;
    p=p->next;
    while(p!=NULL)
    {
        if(p->data.num==c)
        {
      scanf("%d%s%s%s%s%s%s%s%s%s%s%s%d",&s.num,&s.name,&s.title,&s.sex,&s.kcmc1,&s.stage1,&s.nature1,&s.jxxg1,s.kcmc2,&s.stage2,&s.nature2,&s.jxxg2,&s.zhpf);
        p->data=s;break;
        }p=p->next;
    }
    return ;
};
void delete1()
{
    int i;
    struct ST * p;
    p=Head;
    p=p->next;
    while(p!=NULL)
    {
        if(strcmp(d,p->data.name)==0)
        { p->hed->next=p->next;
          p->next->hed=p->hed;break;
        }
     p=p->next;
    }

}
int main()
{    int c,i;

    while(scanf("%s",&b))
    {   getchar();
        if(strcmp(b,"input")==0)
        {
            scanf("%d",&c);
            for(i=0;i<c;i++)
            {
                input();
            }
        }
        else if(strcmp(b,"display")==0)
        {   display();
        }
        else if(strcmp(b,"search")==0)
        {
            search1();
        }
        else if(strcmp(b,"sort")==0)
        {    scanf("%d",&c);
            sort1(c);
        }
        else if(strcmp(b,"insert")==0)
        {
            insert1();
        }
        else if(strcmp(b,"change")==0)
        {  scanf("%d",&c);
            change(c);
        }
        else if(strcmp(b,"delete")==0)
        {
            scanf("%s",&d);
            delete1();
        }
        else if(strcmp(b,"quit")==0)
            break;

    }return 0;
}


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
char b[30],d[20];
int l;
struct S{
    int num;
    char name[30];
    char title[20];
    char sex[30];
    char kcmc1[30];
    char stage1[30];
    char nature1[30];
    char jxxg1[20];
    char kcmc2[30];
    char stage2[30];
    char nature2[30];
    char jxxg2[30];
    int zhpf;
    int mak;
};
struct ST
{
    S data;
    struct ST *hed;
    struct ST *next;
};
struct ST *createNullList()
{
    struct ST *head;
    head=(struct ST*)malloc(sizeof(struct ST));
    if(head!=NULL)
	{head->next=NULL;head->hed=NULL;}
    return head;
};
struct ST *Head=createNullList();
void connect(struct ST*node)
{
    struct ST* p;
    p=Head;
    while(p->next!=NULL)
        p=p->next;
    p->next=node;
	node->hed=p;

};
void deleteList(struct ST* node)
{
    struct ST* p;
    p=Head;
    node->next->hed=node->hed;
    node->hed->next=node->next;
    while(p==node)
    {
        p=p->hed;
    }
};
int isNullList(struct ST* head)
{
    return head->next==NULL;
};
int getlength(struct ST*Head)
{
    int sum=0;
    struct ST * p;
    p=Head;
    p=p->next;
    while(p!=NULL)
    {
        sum++;
        p=p->next;
    }return sum;
}
void input()
{  S s;
   scanf("%d%s%s%s%s%s%s%s%s%s%s%s%d",&s.num,&s.name,&s.title,&s.sex,&s.kcmc1,&s.stage1,&s.nature1,&s.jxxg1,s.kcmc2,&s.stage2,&s.nature2,&s.jxxg2,&s.zhpf);
   struct ST* node=createNullList();
   node->data=s;
   connect(node);
};
void display()
{   struct ST * p;
    p=Head;
    p=p->next;
    while(p!=NULL)
    {printf("%ld %s %s %s %s %s %s %s %s %s %s %s %d\n",p->data.num,p->data.name,p->data.title,p->data.sex,p->data.kcmc1,p->data.stage1,p->data.nature1,p->data.jxxg1,p->data.kcmc2,p->data.stage2,p->data.nature2,p->data.jxxg2,p->data.zhpf);
      p=p->next;
    }
};
void search1()
{    int i,o=0;
    scanf("%s",&d);
    struct ST * p;
    p=Head;
    p=p->next;
    while(p!=NULL)
        {if(strcmp(p->data.name,d)==0||strcmp(p->data.kcmc1,d)==0||strcmp(p->data.kcmc2,d)==0)
           {o=1;printf("%ld %s %s %s %s %s %s %s %s %s %s %s %d\n",p->data.num,p->data.name,p->data.title,p->data.sex,p->data.kcmc1,p->data.stage1,p->data.nature1,p->data.jxxg1,p->data.kcmc2,p->data.stage2,p->data.nature2,p->data.jxxg2,p->data.zhpf);

           } p=p->next;
        }
    if(o==0)
        printf("NO match!\n");
    for(i=0;i<20;i++)
        d[i]=0;
};
void sort1(int c)
{   S s;
    int i,j,k;
    struct ST * p1,*p2;
    p1=Head;
    p1=p1->next;
    p2=Head;
    l=getlength(p1)+1;
    struct ST * p;
    p=Head;
    p=p->next;
    if(c==0)
        for(i=0;i<l-1;i++)
    {  p=p2->next;
     for(j = 0; j <l - 1 - i; j++){
        if(p->data.num < p->next->data.num){
            s= p->data;
            p->data = p->next->data;
            p->next->data = s;
                }
                p = p->next;
            }
        }
        else if(c==1)
        for(i=0;i<l-1;i++)
           {p=p2->next;
           for(j = 0; j <l - 1 - i; j++){
                if(p->data.zhpf < p->next->data.zhpf){
                    s = p->data;
                    p->data = p->next->data;
                    p->next->data = s;
                }
                p= p->next;
            }
        }





    return ;
};
void insert1()
{

   S s;
   scanf("%d%s%s%s%s%s%s%s%s%s%s%s%d",&s.num,&s.name,&s.title,&s.sex,&s.kcmc1,&s.stage1,&s.nature1,&s.jxxg1,s.kcmc2,&s.stage2,&s.nature2,&s.jxxg2,&s.zhpf);
   struct ST* node=createNullList();
   node->data=s;
   connect(node);
    return ;
};
void change(int c)
{   int i;S s;
    struct ST * p;
    p=Head;
    p=p->next;
    while(p!=NULL)
    {
        if(p->data.num==c)
        {
      scanf("%d%s%s%s%s%s%s%s%s%s%s%s%d",&s.num,&s.name,&s.title,&s.sex,&s.kcmc1,&s.stage1,&s.nature1,&s.jxxg1,s.kcmc2,&s.stage2,&s.nature2,&s.jxxg2,&s.zhpf);
        p->data=s;break;
        }p=p->next;
    }
    return ;
};
void delete1()
{
    int i;
    struct ST * p;
    p=Head;
    p=p->next;
    while(p!=NULL)
    {
        if(strcmp(d,p->data.name)==0)
        { p->hed->next=p->next;
          p->next->hed=p->hed;break;
        }
     p=p->next;
    }

}
int main()
{    int c,i;

    while(scanf("%s",&b))
    {   getchar();
        if(strcmp(b,"input")==0)
        {
            scanf("%d",&c);
            for(i=0;i<c;i++)
            {
                input();
            }
        }
        else if(strcmp(b,"display")==0)
        {   display();
        }
        else if(strcmp(b,"search")==0)
        {
            search1();
        }
        else if(strcmp(b,"sort")==0)
        {    scanf("%d",&c);
            sort1(c);
        }
        else if(strcmp(b,"insert")==0)
        {
            insert1();
        }
        else if(strcmp(b,"change")==0)
        {  scanf("%d",&c);
            change(c);
        }
        else if(strcmp(b,"delete")==0)
        {
            scanf("%s",&d);
            delete1();
        }
        else if(strcmp(b,"quit")==0)
            break;

    }return 0;
}


  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值