| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 929 人关注过本帖
标题:数据结构的课程设计
只看楼主 加入收藏
小不点。丫头
Rank: 1
来 自:安徽
等 级:新手上路
帖 子:3
专家分:0
注 册:2012-6-10
结帖率:0
收藏
已结贴  问题点数:20 回复次数:5 
数据结构的课程设计
主要的算法是:
初始链表的建立;
对链表按总分降序排序;
排名次;
主函数;
"我没有做出来做一半的";
# include <stdlib.h>
#include<malloc.h>
#include <string.h>
typedef struct student
    {  char num[6];
       char name[8];
        int tax;
        int english ;
        int math;
        int score;
        struct student *next;
    }jd;
jd *h,*head1,*end,*head,*r[];
output( jd *head1)
    {
        jd *q;
        q=head1->next;
        while(q!=NULL)
        {
            printf("%s\t\t%s\t\t%d\t\t%d\n",q->num,q->name,q->english,q->math);
            q=q->next;
        }
        printf("\n");
    }
foutput(jd *head1)
    {
        FILE *fp1;
        jd *q;
        fp1=fopen("student.txt","w");
        if(fp1==NULL)
        {
            printf("无法打开文件!\n");
            exit(0);
        }
        q=head->next;
        while(q!=NULL)
        {
            fprintf(fp1,"%s\t\t%s\t\t%d\t\t%d\n",q->num,q->name,q->english,q->math);
            q=q->next;
        }
        fclose(fp1);
    }                  
               
creat()
    {    jd *end,*p;
        FILE *fp;
        fp=fopen("student.txt","r"); //以只读方式打开当前目录下的家庭图书信息.txt
        if(fp==NULL)
        {
            printf("无法打开文件");
            exit(0);    //-------- 终止程序 ---------
        }
        h=(jd *)malloc(sizeof(jd));
        end=h;
        end->next=NULL;
        while(!feof(fp)) //------!feof(fp)值为0,不在执行循环语句  ------
        {
            p=(jd *)malloc(sizeof(jd));
            fscanf(fp,"%s%s%d%d\n",&p->num,&p->name,&p->english,&p->math);
            p->next=NULL;
            end->next=p;
            end=p;
        }
        output (h);
        fclose(fp);//----关闭文件-----
 peixu()
    {
        int m,n;                                    
        char num[6];
        creat();
        printf("请输入学号:");
        scanf("%s",&num);
        p=h->next;
        while(p!=NULL)
        {
            if(strcmp(num,p->num)==0)
            {
                p->score=p->english+p->math;
            }
            p=p->next;
        }
        output(p);
    }
 void insert_sort(jd *r[],int n)
 {  int i,j;
    for(i=2;i<n;i++)
    {  r[0]=r[i];
       j=i-1;
       while(r[0].score<r[i].score)
       {
           r[j++]=r[j];
           j--;

       }
       r[j+1]=r[0];
    }
 }

 main()
    { int n;
       printf("\t  欢迎使用成绩排名管理系统!\n\n");
      while(1)
         { printf("\t    成绩排名管理系统程序\n\n");
                printf("================我的菜单====================\n");
                printf("\t  1.链表的建立\n");
                printf("\t  2.对链表按总分降序排序\n");
                printf("\t  3.对成绩表排名次\n");
                printf("\t  0.退出\n");
                printf("============================================\n");
                printf("\t\t请选择:");
                scanf("%d",&n);
             if((n>=0) && (n<=2))
             {  switch(n)
                {   
                    case 1:creat();break;
                    case 2:insert_sort();break;
                    case 0:exit(0);
                }
             printf("\n操作完毕,请再次选择\n!");
             }
          else
          printf("感谢您的使用!!!\n\n");
         }
    }
搜索更多相关主题的帖子: 课程 include next 
2012-06-10 16:00
小不点。丫头
Rank: 1
来 自:安徽
等 级:新手上路
帖 子:3
专家分:0
注 册:2012-6-10
收藏
得分:0 
希望大家帮忙看看啊
2012-06-10 16:01
小虎虎
Rank: 2
等 级:论坛游民
帖 子:3
专家分:10
注 册:2012-6-11
收藏
得分:10 
刚学,不太会
2012-06-11 16:44
gao114329976
Rank: 2
等 级:论坛游民
帖 子:3
专家分:10
注 册:2012-6-12
收藏
得分:10 
你只是用链表来排序吗
2012-06-12 15:22
海阔天空!
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2012-6-19
收藏
得分:0 
呵呵呵,数据结构是要学好
2012-06-25 21:23
海阔天空!
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2012-6-19
收藏
得分:0 
数据结构和算法很重要的

2012-06-25 21:24
快速回复:数据结构的课程设计
数据加载中...
 
   



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

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