| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 758 人关注过本帖, 1 人收藏
标题:小型学生管理系统
只看楼主 加入收藏
wbajieng
Rank: 1
等 级:新手上路
帖 子:20
专家分:1
注 册:2010-3-28
结帖率:71.43%
收藏(1)
已结贴  问题点数:20 回复次数:4 
小型学生管理系统
#include<stdio.h>
#include<malloc.h>
#include<stdlib.h>
#include<string.h>
typedef struct stu{
    char Name[15];
    char Id[15];
    int Com;
    int Math;
    int Eng;
    int Phy;
    stu * next;
}stu;
stu* s;
stu* Luru(void);
void Xiugai(stu* head);
void Delete(stu* head);
void Chaxun(stu* head);
int main()
{
    int n;
    printf("录入学生信息按1\n修改学生信息按2\n删除学生信息按3\n查询学生信息按4\n退出按0\n");
    scanf("%d",&n);
    while(n!=0){
            if(n==1) s=Luru();
            if(n==2) Xiugai(s);
            if(n==3) Delete(s);
            if(n==4) Chaxun(s);
            scanf("%d",&n);
            }
            system("pause");
            return 0;
}
stu* Luru(void){
    struct stu * head,*p,*q;
    int i,m;
    printf("请输入学生个数:");
        scanf("%d",&m);
    p=( stu * ) malloc(sizeof( stu));
    if(p==NULL) {
        printf("分配空间失败");
        exit(0);
    }        
        head=p;
    for(i=1;i<=m;i++){
        q=(struct stu * )malloc(sizeof(struct stu));
        if(q==NULL) {
        printf("分配空间失败");
        exit(0);
        }
            printf("姓名 学号 计算机 数学 英语 物理:");
            scanf("%s %s %d %d %d %d",q->Name,q->Id,&q->Com,&q->Math,&q->Eng,&q->Phy);
            p->next=q;
            p=q;
    }
    p->next=NULL;
    return head;
}
void Xiugai(stu* head){
    char a[15];
    stu* p;
    int k,i;
    printf("请输入要修改的学生数:");
    scanf("%d",&k);
    for(i=1;i<=k;i++){
        printf("请输入要修改的学生的学号:");
        scanf("%s",a);
        p=head;
        p=p->next;
        while(strcmp(a,p->Id)!=0)
        p=p->next;
        if(strcmp(a,p->Id)==0){
        printf("请重新输入该学生的信息:");
        scanf("%s %s %d %d %d %d",p->Name,p->Id,&p->Com,&p->Math,&p->Eng,&p->Phy);
        }
        else printf("学号有误,未找到");
        
    }
   
}
void Chaxun(stu* head){
        char a[15];
        stu* p;
        printf("请输入要查询学生的学号:(退出按0)");
        scanf("%s",a);
        while(strcmp(a,"0")!=0){
            p=head;
             p=p->next;
            while(strcmp(a,p->Id)!=0)
            p=p->next;
            if(strcmp(a,p->Id)==0)
                printf("姓名:%s 学号:%s 计算机:%d 数学:%d 英语:%d 物理:%d",p->Name,p->Id,p->Com,p->Math,p->Eng,p->Phy);
             else printf("学号有误。");
            scanf("%s",a);
        }
}
void Delete(stu* head){
    char a[15];
    stu* p;
    stu* q;
    printf("请输入要删除学生的学号:(退出按0)");
    scanf("%s",a);
    while(strcmp(a,"0")!=0){
        p=head;
        while(strcmp(a,p->next->Id)!=0)
            p=p->next;
        if(strcmp(a,p->next->Id)==0){
            q=p->next;
            p->next=p->next->next;
            free(q);
        }
        scanf("%s",a);
    }
}



   
   


   

搜索更多相关主题的帖子: 系统 学生 管理 
2010-04-21 16:32
寒风中的细雨
Rank: 17Rank: 17Rank: 17Rank: 17Rank: 17
等 级:贵宾
威 望:66
帖 子:1710
专家分:8645
注 册:2009-9-15
收藏
得分:20 
干什么?
2010-04-22 06:50
wbajieng
Rank: 1
等 级:新手上路
帖 子:20
专家分:1
注 册:2010-3-28
收藏
得分:0 
录入、修改、删除和查询学生信息
2010-04-24 00:26
寒风中的细雨
Rank: 17Rank: 17Rank: 17Rank: 17Rank: 17
等 级:贵宾
威 望:66
帖 子:1710
专家分:8645
注 册:2009-9-15
收藏
得分:0 
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
#include <string.h>

typedef struct stu
{
    char Name[15];
    char Id[15];
    int Com;
    int Math;
    int Eng;
    int Phy;
    stu * next;
}stu;
stu* s = NULL;
stu* Luru(void);
void Xiugai(stu* head);
void Delete(stu* head);
void Chaxun(stu* head);
int main()
{
    int n;
    printf("录入学生信息按1\n修改学生信息按2\n删除学生信息按3\n查询学生信息按4\n退出按0\n");
    scanf("%d",&n);
    while(n!=0){
            if(n==1) s=Luru();
            if(n==2) Xiugai(s);
            if(n==3) Delete(s);
            if(n==4) Chaxun(s);
            scanf("%d",&n);
            }
            system("pause");
            return 0;
}

stu* Luru(void)
{
    struct stu * head = NULL,*p,*q;
    int i,m;
    printf("请输入学生个数:");
        scanf("%d",&m);
    p=( stu * ) malloc(sizeof( stu));
    if(p==NULL) {
        printf("分配空间失败");
        exit(0);
    }        
    head=p;
    for(i=1;i<=m;i++){
        q=(struct stu * )malloc(sizeof(struct stu));
        if(q==NULL) {
        printf("分配空间失败");
        exit(0);
        }
            printf("姓名 学号 计算机 数学 英语 物理:");
            scanf("%s %s %d %d %d %d",q->Name,q->Id,&q->Com,&q->Math,&q->Eng,&q->Phy);
            p->next=q;
            p=q;
    }
    p->next=NULL;
    printf("信息添加成功!\n");
    return head;
}
void Xiugai(stu* head)
{
    if( !head )
    {
        printf("No students msg!\n");
        return;
    }
    char a[15];
    stu* p;
    int k,i;
    printf("请输入要修改的学生数:");
    scanf("%d",&k);
    for(i=1;i<=k;i++){
        printf("请输入要修改的学生的学号:");
        scanf("%s",a);
        p=head;
        p=p->next;
        while(strcmp(a,p->Id)!=0)
        p=p->next;
        if(strcmp(a,p->Id)==0){
        printf("请重新输入该学生的信息:");
        scanf("%s %s %d %d %d %d",p->Name,p->Id,&p->Com,&p->Math,&p->Eng,&p->Phy);
        }
        else printf("学号有误,未找到");
        
    }
   
}
void Chaxun(stu* head)
{
    if( !head )
    {
        printf("No students msg!\n");
        return;
    }
        char a[15];
        stu* p;
        printf("请输入要查询学生的学号:(退出按0)");
        scanf("%s",a);
        while(strcmp(a,"0")!=0){
            p=head;
             p=p->next;
            while(strcmp(a,p->Id)!=0)
            p=p->next;
            if(strcmp(a,p->Id)==0)
                printf("姓名:%s 学号:%s 计算机:%d 数学:%d 英语:%d 物理:%d",p->Name,p->Id,p->Com,p->Math,p->Eng,p->Phy);
             else printf("学号有误。");
            scanf("%s",a);
        }
}
void Delete(stu* head){
    if( !head )
    {
        printf("No students msg!\n");
        return;
    }
    char a[15];
    stu* p;
    stu* q;
    printf("请输入要删除学生的学号:(退出按0)");
    scanf("%s",a);
    while(strcmp(a,"0")!=0){
        p=head;
        while(strcmp(a,p->next->Id)!=0)
            p=p->next;
        if(strcmp(a,p->next->Id)==0){
            q=p->next;
            p->next=p->next->next;
            free(q);
        }
        scanf("%s",a);
    }
}

2010-04-27 07:32
新绿
Rank: 1
等 级:新手上路
帖 子:15
专家分:7
注 册:2010-4-26
收藏
得分:0 
有什么不一样的?
2010-05-11 16:38
快速回复:小型学生管理系统
数据加载中...
 
   



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

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