chen_rui_heng_525
pana hema
采纳率100%
2017-05-30 07:57 阅读 3.0k
已采纳

c语言课程设计:学生档案管理系统

30

要求有5个功能。1 输入功能:录入学生信息;
2 显示功能:完成学生记录的显示;
3 查找功能:完成查看所有学生,按学号或姓名查找学生的相关记录,并显示;
4 更新功能:(增加或删除)。
利用结构体数组实现学生信息的数据结构设计,且各个功能模块用函数的形式实现。(加注释的话更好)

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    Histheme Histheme 2017-05-30 08:03

    #include
    #include
    #include
    #include
    #include
    struct studentding{
    char name[19];
    int goal[3];
    int xuenum;
    };
    int stunum;
    struct studentding student;
    int searchnum;
    int cmp(const void*a,const void *b)//¿ìÅŵĶԱȺ¯Êý
    {
    return ((
    (struct studentding )a).xuenum-((struct studentding )b).xuenum>0?1:-1);
    }
    void inputmes()//ÊäÈë
    {
    int x;
    puts("How many students do you have ?");
    scanf("%d",&stunum);
    student=(struct studentding *)malloc(stunum*sizeof(struct studentding)); //¶¯Ì¬ÄÚ´æ·ÖÅä¸ø½á¹¹ÌåÊý×é
    for(x=0;x {
    printf("input a student id:");
    scanf("%d",&student[x].xuenum);
    getchar();
    printf("input a student name contain less than 19 characters:");
    gets((student+x)->name);
    printf("input 3 scores:");
    scanf("%d%d%d",&student[x].goal[0],&student[x].goal[1],&student[x].goal[2]);
    while(getchar()!='\n');//³ÔµôÈ«²¿µÄ»»Ðзû
    }
    qsort(student,stunum,sizeof(struct studentding),cmp);//¿ìÅŵÄÔËÓÃ
    }
    void outputmes()
    {
    int x;
    printf("please input the id of the student which you want to search:");
    scanf("%d",&searchnum);
    getchar();
    x=search();
    if(x>=0)
    {
    printf("student id:%d name :\t%s,scores:",student[x].xuenum,student[x].name);
    printf("<%d %d %d>\n",student[x].goal[0],student[x].goal[1],student[x].goal[2]);
    }
    else
    return;
    }
    int search()//¶þ·Ö·¨²éÕÒ
    {
    int x;
    if(searchnum==student[stunum/2].xuenum)
    return stunum/2;
    else if(searchnum>student[stunum/2].xuenum)
    {
    for(x=stunum/2;x if(searchnum==student[x].xuenum)
    return x;
    puts("Not found!");
    return -1;
    }
    else if(searchnum {
    for(x=stunum/2;x>=0;x--)
    if(searchnum==student[x].xuenum)
    return x;
    puts("Not found!");
    return -1;
    }
    }
    void dele()//ɾ³ýѧÉúÐÅÏ¢
    {
    int x;
    int y;
    printf("please input the student id which you want to delete:");
    scanf("%d",&searchnum);
    getchar();
    x=search();
    if(x>=0)
    {
    memmove(&student[x],&student[x+1],sizeof(student[0])
    (stunum-x-1));
    stunum-=1;
    }
    else
    return;
    }
    int main()
    {
    char ch;
    inputmes();
    while(1)//Èý¸öÑ¡Ïî
    {
    puts("what do you select ? please press not input\na:search a student and his massage.\nb:delete a student\nc:exit ");
    ch=getch();
    if(ch=='a')//Ñ¡ÔñµÄ²Ëµ¥
    {
    outputmes();
    puts("press r to return");
    ch=getch();
    system("cls");
    }
    else if(ch=='b')
    {
    dele();
    puts("press r to return");
    ch=getch();
    system("cls");
    }
    else if(ch=='c')//Í˳öµÄÌõ¼þ
    return;
    else
    {
    puts("No,please press a ,b or c");
    sleep(1);
    system("cls");
    }
    }
    }
    去年学c时候做的,感觉应该还能用

    点赞 评论 复制链接分享

相关推荐