| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1183 人关注过本帖
标题:单文件版学生信息管理系统,删除有问题
只看楼主 加入收藏
qq_s15
Rank: 2
等 级:论坛游民
帖 子:30
专家分:28
注 册:2015-7-18
结帖率:100%
收藏
 问题点数:0 回复次数:1 
单文件版学生信息管理系统,删除有问题
全代码如下。
下面代码其实不用全部。
便于大神帮忙修改。
谢谢!

就是删除那里出问题
删除完之后信息还是保留着。
怎么清除。。
图片附件: 游客没有浏览图片的权限,请 登录注册


# include <stdio.h>
# include <stdlib.h>
# include <conio.h>
# include <string.h>
# include <windows.h>


struct StuMsg    //学生信息
{
    char id[4];                //学生学号
    char name[10];            //学生名字
    int  age;                //学生年龄
    char sex[8];            //性别
    char birthday[20];        //生日
    char tel[15];            //电话
    char address[70];        //地址
    char email[20];            //邮件
}st[20];

int i=0;
int j;
void shuru(void);            //输入函数
void XianShi(void);            //显示函数
void ChaName(void);            //由名字查询函数
void ChaNo(void);            //由学号查询函数
void Dle(void);                //删除函数
void XiuGai(void);            //修改函数
void CaiDan(void);            //菜单函数

void main()                    //主函数
{
   
    CaiDan();                //调用菜单函数
   
}

/*-------------------------菜单函数-------------------------------*/
void CaiDan(void)            
{
    int i;
    for (;;)
    {
        system("cls");
        printf("\n");
        printf("\n");
        printf("\n");
        printf("============================学生信息管理系统===================================\n");
        printf("||                                                                           ||\n");
        printf("||                                                                           ||\n");
        printf("||                                                                           ||\n");
        printf("||                                                                           ||\n");
        printf("||                          一: 输入学生信息                                ||\n");
        printf("||                          二: 显示学生信息                                ||\n");
        printf("||                          三: 查找学生姓名信息                            ||\n");
        printf("||                          四:  查找学生学号信息                            ||\n");
        printf("||                          五: 删除学生信息                                ||\n");
        printf("||                          六: 修改学生信息                                ||\n");
        printf("||                          七: 退出程序                                    ||\n");
        printf("||                                                                           ||\n");
        printf("||                                                                           ||\n");
        printf("===============================================================================\n");
        fflush(stdin);
        printf("\n");
        printf("\n");
        printf("\t\t   请输入功能选项:");

        scanf("%d", &i);
        switch (i)
        {
        case 1:
            shuru();
            break;
        case 2:
            XianShi();
            break;
        case 3:
            ChaName();
            break;
        case 4:
            ChaNo();
            break;
        case 5:
            Dle();
            break;
        case 6:
            XiuGai();
            break;
        case 7:
            exit(0);
        }
    }


}


/*-------------------------学生信息输入函数-------------------------------*/
void shuru(void)        
{
    char a;
    system("cls");
   
    printf("请输入学生信息:\n");
    do{

        printf("请输入第%d个学生学号:", i + 1);
        scanf("%s", &st[i].id);
        printf("请输入第%d个学生姓名:", i + 1);
        scanf("%s", &st[i].name);
        printf("请输入第%d个学生年龄:", i + 1);
        scanf("%d", &st[i].age);
        printf("请输入第%d个学生性别:", i + 1);
        scanf("%s", &st[i].sex);
        printf("请输入第%d个学生生日:", i + 1);
        scanf("%s", &st[i].birthday);
        printf("请输入第%d个学生电话:", i + 1);
        scanf("%s", &st[i].tel);
        printf("请输入第%d个学生地址:", i + 1);
        scanf("%s", &st[i].address);
        printf("请输入第%d个学生邮箱:", i + 1);
        scanf("%s", &st[i].email);
        printf("\n是否继续输入另外一个学生信息?(y/n)");
        fflush(stdin);
        a = getchar();
        i++;
    } while (a == 'y' && i <= 50);
    CaiDan();                //调用菜单函数
}


/*-------------------------显示函数-------------------------------*/
void XianShi(void)
{
    system("cls");
    for (j = 0; j < i; j++)
    {
        printf("第%d个学生学号是:", j + 1);
        printf("%s\n", st[j].id);
        printf("第%d个学生姓名是:", j + 1);
        printf("%s\n", st[j].name);
        fflush(stdin);
        printf("第%d个学生年龄是:", j + 1);
        printf("%d\n", st[j].age);
        fflush(stdin);
        printf("第%d个学生性别是:", j + 1);
        printf("%s\n", st[j].sex);
        printf("第%d个学生生日是:", j + 1);
        printf("%s\n", st[j].birthday);
        printf("第%d个学生电话是:", j + 1);
        printf("%s\n", st[j].tel);
        printf("第%d个学生地址是:", j + 1);
        printf("%s\n", st[j].address);
        printf("第%d个学生邮箱是:", j + 1);
        printf("%s\n", st[j].email);
        printf("\n\n");
    }
    system("pause");
    CaiDan();
}


/*-------------------------按照名字查询函数-------------------------------*/
void ChaName(void)
{
    char name[10];
    int i;
    system("cls");
    printf("请输入你要查找的学生姓名:");
    scanf("%s", name);
    for (i = 0; i < j; i++)
    {
        if (strcmp(name, st[i].name) == 0)
        {
            printf("该学生学号是:");
            printf("%s\n", st[i].id);
            printf("该学生姓名是:");
            printf("%s\n", st[i].name);
            printf("该学生年龄是:");
            printf("%s\n", st[i].age);
            printf("该学生性别是:");
            printf("%s\n", st[i].sex);
            printf("该学生生日是:");
            printf("%s\n", st[i].birthday);
            printf("该学生电话是:");
            printf("%s\n", st[i].tel);
            printf("该学生地址是:");
            printf("%s\n", st[i].address);
            printf("该学生邮箱是:");
            printf("%s\n", st[i].email);
        }
    }
    system("pause");
    CaiDan();
}

/*-------------------------按照学号查询函数-------------------------------*/
void ChaNo(void)
{
    char i[4];
    int k;
    system("cls");
    printf("请输入你要查找的学生学号:");
    scanf("%s", i);
    for (k = 0; k < j; k++)
    {
        if (strcmp(i, st[k].id) == 0)        //判断输入学号与保存学号是否相同,相同则输出对应学号学生信息
        {
            printf("该学生学号是:");
            printf("%s\n", st[k].id);
            printf("该学生姓名是:");
            printf("%s\n", st[k].name);
            printf("该学生年龄是:");
            printf("%d\n", st[k].age);
            printf("该学生性别是:");
            printf("%s\n", st[k].sex);
            printf("该学生生日是:");
            printf("%s\n", st[k].birthday);
            printf("该学生电话是:");
            printf("%s\n", st[k].tel);
            printf("该学生地址是:");
            printf("%s\n", st[k].address);
            printf("该学生邮箱是:");
            printf("%s\n", st[k].email);
        }
    }
    system("pause");
    CaiDan();
}


/*-------------------------学生信息输入函数-------------------------------*/
void Dle(void)
{
    char id[4];
    int k;
    int a;
    system("cls");
    printf("请输入要删除学生的学号:");
    scanf("%s",id);
    for (k = 0; k < i; k++)
    {
        if (strcmp(id, st[k].id) == 0)
        {
            break;
        }
        else
        {
            printf("没有找到该学生");
        }
    }
    for (a = 0; a < i; a++)
    {
        st[a] = st[a + 1];
    }

    fflush(stdin);
    system("pause");
    CaiDan();
}



/*-------------------------修改函数-------------------------------*/
void XiuGai(void)
{
    char id[4];
    int i;
    system("cls");
    XianShi();
   
    printf("\n请输入需要修改学生的学号:");
    scanf("%s",&id);

    for (i = 0; i < j; i++)
    {
        if (strcmp(id, st[i].id) == 0)
        {
            printf("请输入学生学号:");
            scanf("%s", &st[i].id);
            printf("请输入学生姓名:");
            scanf("%s", &st[i].name);
            printf("请输入学生年龄:");
            scanf("%d", &st[i].age);
            fflush(stdin);
            printf("请输入学生性别:");
            scanf("%s", &st[i].sex);
            printf("请输入学生生日:");
            scanf("%s", &st[i].birthday);
            printf("请输入学生电话:");
            scanf("%s", &st[i].tel);
            printf("请输入学生地址:");
            scanf("%s", &st[i].address);
            printf("请输入学生邮箱:");
            scanf("%s", &st[i].email);
        }
    }
    CaiDan();
}
搜索更多相关主题的帖子: 管理系统 include 信息 生日 
2016-01-18 19:42
沙大少
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2016-1-3
收藏
得分:0 
2016-01-22 11:13
快速回复:单文件版学生信息管理系统,删除有问题
数据加载中...
 
   



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

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