标题:望版主,沉掉此贴____都是些坑啊
只看楼主
々NARUTO
Rank: 2
等 级:论坛游民
帖 子:80
专家分:85
注 册:2011-6-19
结帖率:77.78%
 问题点数:0 回复次数:4 
望版主,沉掉此贴____都是些坑啊
妹的 之前 发错了 板块 !  移动不了 了
问题 在这:https://bbs.bccn.net/thread-404963-1-1.html

[ 本帖最后由 々NARUTO 于 2013-4-21 12:25 编辑 ]
搜索更多相关主题的帖子: 板块 移动 
2013-04-20 13:29
々NARUTO
Rank: 2
等 级:论坛游民
帖 子:80
专家分:85
注 册:2011-6-19
得分:0 
怎么C 论坛 里每一个人 回答啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊
版主都去哪了???????
2013-04-20 14:08
尔东
Rank: 2
等 级:论坛游民
帖 子:14
专家分:44
注 册:2013-4-19
得分:0 
要求有什么功能?
2013-04-20 21:38
不眠的夜
Rank: 2
等 级:论坛游民
帖 子:63
专家分:96
注 册:2013-3-12
得分:0 
C程序 学生管理系统
/* Note:Your choice is C IDE */
#include "stdio.h"
#include"stdlib.h"
#include"string.h"


typedef struct student//定义学生
{
    char name[10];
    int number;
    char sex[2];
    int math;
    int eglish;
    int clanguge;
    int average;
}student;

typedef struct unit//定义接点
{
    student date;
    struct unit *next;
}unit;


unit* build()//建立链表并返回指针
{
    unit *p;
    if((p=(unit*)malloc(sizeof(unit)))==NULL)
     { printf("=>初始化失败!");
         return 0;
     }
    else
     {p->next=NULL;
         p->date.number=0;//头结点存放学生人数
      printf("初始化成功!\n");
      return p;
     }
}


void add(unit *head)//增加学生
{
    unit *p,*q;
    int m,n=0;
    q=head->next;
    p=(unit*)malloc(sizeof(unit));
    printf("=>请输入新生姓名!\n");
    gets(p->date.name);fflush(stdin);
    printf("=>请输入学号!\n");
    while(n==0)
    {
        scanf("%d",&m);fflush(stdin);
        if(q==NULL) n=1;
        while(q)
        {
            if(q->date.number==m)
            {
               printf("=>你输入的学号与已有同学的学号相同,请重新输入!\n");
               q=head->next;
               break;
            }
        
            else
            {
               q=q->next;
               if(q==NULL) n=1;
            }
        }
    }
    p->date.number=m;
    printf("=>请输入性别!\n");
    gets(p->date.sex);fflush(stdin);
    printf("=>请输入数学成绩\n");
    scanf("%d",&m);fflush(stdin);
    p->date.math=m;
    printf("=>请输入英语成绩\n");
    scanf("%d",&m);fflush(stdin);
    p->date.eglish=m;
    printf("=>请输入c语言成绩\n");
    scanf("%d",&m);fflush(stdin);
    p->date.clanguge=m;
    p->date.average=(p->date.math+p->date.eglish+p->date.clanguge);
    q=head->next;
    head->next=p;
    p->next=q;
    head->date.number++;
}
   

void deletion(unit *head)//删除一名学生
{
    unit *p=head->next,*q=head;
    char N[10];
    printf("=>请输入你想删除的学生姓名!\n");
    gets(N);fflush(stdin);
    if(p==NULL)
    printf("=>系统无学生可删除!\n");
    while(p)
    {
        if(strcmp(p->date.name,N)==0)
        {
            q->next=p->next;
            head->date.number--;
            printf("=>删除%s成功!\n",p->date.name);
            free(p);
            break;
        }
        else
        {
            p=p->next;
            q=q->next;
            if(p==NULL)
            printf("=>你要删除的学生不存在,删除失败!\n");
        }
    }

}


int display(unit *head)//显示学生信息
{
    unit *p=head->next;
    int m,n=0;
    char N[10];
    if(p==NULL)
    {
        printf("=>系统无学生!\n");
        return 0;
    }
    while(n==0)
    {
        printf("******************************************************************************\n");
        printf("=>请选择你的操作!\n");
        printf("=>\t\t\t1.显示所有\t2.按姓名查找\n\t\t\t3.按学号查找\t4.返回主菜单\n");
        scanf("%d",&m);
        fflush(stdin);
        switch(m)
        {
            case 1:printf("\n=>该系统拥有%d名学生!\n\n",head->date.number);
                   p=head->next;
                   printf("\t姓名\t学号\t性别\t数学\t英语\tc语言\t综合\n\n");
                   while(p)
                    {
                        printf("\t%s\t%d\t%s\t%d\t%d\t%d\t%d\n",p->date.name,p->date.number,p->date.sex,p->date.math,
                        p->date.eglish,p->date.clanguge,p->date.average);
                        p=p->next;
                    }
                    break;
            case 2:printf("=>请输入查找姓名!\n");
                   gets(N);
                   fflush(stdin);
                   p=head->next;
                  while(p)
                   {
                       if(strcmp(p->date.name,N)==0)
                    {
                        printf("\t姓名\t学号\t性别\t数学\t英语\tc语言\t综合\n");
                        printf("\t%s\t%d\t%s\t%d\t%d\t%d\t%d\n",p->date.name,p->date.number,p->date.sex,p->date.math,
                        p->date.eglish,p->date.clanguge,p->date.average);
                        break;
                    }
                    else
                    {
                        p=p->next;
                        if(p==NULL)
                        printf("=>你要查的学生不存在!");
                    }
                   }
                    break;
              case 3: printf("=>请输入查找学号!\n");
                   scanf("%d",&m);
                   fflush(stdin);
                  p=head->next;
                  while(p)
                   {
                       if(p->date.number==m)
                    {
                        printf("\t姓名\t学号\t性别\t数学\t英语\tc语言\t综合\n");
                        printf("\t%s\t%d\t%s\t%d\t%d\t%d\t%d\n",p->date.name,p->date.number,p->date.sex,p->date.math,
                        p->date.eglish,p->date.clanguge,p->date.average);
                        break;
                    }
                    else
                    {
                        p=p->next;
                        if(p==NULL)
                        printf("=>你要查的学生不存在!\n");
                    }
                   }
                    break;
             case 4:n=1;break;
        }
    }
    return 1;
}
                              



int range(unit *head)//排序
{
    unit *p=head,*q=head->next;
    int n,i,m=head->date.number;
    printf("*******************************************************************************\n");
    printf("\t\t\t1.按学号\t2.按成绩\n\n");
    printf("=>请选择操作!\n》");
    scanf("%d",&n);
    fflush(stdin);
    if(q==NULL)
    { printf("=>无学生可排序!\n");
        return 0;
    }
    switch(n)
    {
        case 2:for(i=0;i<m;i++)//按总分排序
                {
                    p=head;q=head->next;
                    while(q->next)
                    {
                        if((q->date.average)<(q->next->date.average))
                        {
                            p->next=q->next;
                            p=p->next;
                            q->next=p->next;
                            p->next=q;
                        }
                        else
                        {
                            p=p->next;q=q->next;
                        }
                    }
                }
                break;

         case 1:for(i=0;i<=m;i++)//按学号排序
                {
                    p=head;q=head->next;
                    while(q->next)
                    {
                        if((q->date.number)>(q->next->date.number))
                        {
                            p->next=q->next;
                            p=p->next;
                            q->next=p->next;
                            p->next=q;
                        }
                        else
                        {
                            p=p->next;q=q->next;
                        }
                    }
                }
                break;
    }
    printf("=>排序成功!\n");
    return 1;
}




void menu()
{
    printf("\n********************************* 主菜单 ***************************************\n");
   
    printf("\t\t\t1.新建系统\t2.添加学生\n\t\t\t3.删除学生\t4.查看信息\n\t\t\t5.排列顺序\t6.读取信息\n\t\t\t7.保存信息\t8.退出系统\n");
    printf("=>请选择你的操作!\n");
}


int save(unit *head)//保存
{
    FILE *fp;
    unit *p;
    p=head;
    if((fp=fopen("d:\\学生","wb+"))==NULL)
    {
        printf("=>保存失败!");
        return 0;
    }
   while(p)
    {fwrite(&(p->date),sizeof(student),1,fp);
    p=p->next;
    }
    printf("=>保存成功!");
   fclose(fp);
   return 1;
}



unit* read()//读入系统学生信息
{
    int i;
    unit *p,*q,*head;
    FILE *fp;
    if((head=(unit*)malloc(sizeof(unit)))==NULL)
     { printf("=>开辟空间失败!");
         exit(1);
     }
    else
     {
         head->next=NULL;
         head->date.number=0;//头结点存放学生人数
     }
    q=head;
 if((fp=fopen("d:\\学生","rb"))==NULL)
   {printf("=>系统无学生!\n");
    return 0;
    }
 fread(&(q->date),sizeof(student),1,fp);
 for(i=0;i<head->date.number;i++)
 {
     if((p=(unit*)malloc(sizeof(unit)))==NULL)
     { printf("=>读值失败!");
         exit(1);
     }
    fread(&(p->date),sizeof(student),1,fp);
    p->next=q->next;
    q->next=p;
 }
 fclose(fp);
 return head;
}

void main()
{
    int m=0,n, i;
     unit *head;
     printf("********************************************************************************\n\n");
     printf("\t\t\t* 欢迎使用学生成绩管理系统 * \n");
     printf("\n\t\t\t\t\t\t\t\t编译员:岳英明\n\n");
     printf("=>正在读取系统信息......\n");
     if((head=read())==0)
     {
         printf("=>是否新建?\n");
        printf("\t\t\t是(1)\t\t否(2)\n");
           scanf("%d",&i);
           fflush(stdin);
           if(i==1)
             head=build();
           else if(i==2)
             exit(1);
     }
     else
     printf("=>信息导入成功!");
    while(m==0)
    {
        menu();
        scanf("%d",&n);
        fflush(stdin);
     switch(n)
     {
         case 1: head=build();break;
         case 2:add(head);break;
         case 3:deletion(head);break;
         case 4:display(head);break;
         case 5: range(head);break;
         case 6:head=read();if(head!=0) printf("=>读取存盘成功!\n");break;
         case 7:save(head);break;
         case 8:m=1;break;
     }
   }
}
2013-04-21 09:38
谢跃锋
Rank: 2
等 级:论坛游民
威 望:2
帖 子:50
专家分:77
注 册:2013-4-14
得分:0 
回复 4楼 不眠的夜
楼主太强大了,,如果是你自己写出来的,那我彻底拜服了。、、、
2013-04-21 11:41



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-404967-1-1.html




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

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