XiaoHui.net 笑汇程序员论坛首页
工作并快乐着,职业并休闲着
寻梦的岁月从不言辛苦几许,
不问收获几多……
» 游客:  申请新用户 | 登录 | 会员 | 统计 | 帮助 » XiaoHui.Net 笑汇程序员论坛 | 纯文字版 | 全站索引 | XiaoHui.com


[公告] 帮帮忙。。。。

RSS 订阅当前论坛  

上一主题 下一主题
     

标题: [公告] 帮帮忙。。。。  
 
bjbitren
传说中的水手
Rank: 5Rank: 5



UID 29842
精华 0
积分 2
帖子 2
阅读权限 1
注册 2007-3-25
状态 离线
帮帮忙。。。。

我用VC6.0编一个班级成绩统计,并用冒泡法将个人总成绩排序,编译通过,可运行不出结果,那位仁兄能帮忙指点一下?不胜感激......

程序如下:
/*struct*/
#include <stdio.h>
main()
{
struct student                         /*定义结构体并初始化*/
{
        int num;
        char name[20];
        float score[4];
}stu[7]={{20042100,"zhang",85.0,76.0,83.0},
                {20042101,"wang",65.5,45.5,76.0},
                {20042102,"li",76.0,35.0,87.0},
                {20042103,"zhao",89.0,65.0,76.0},
                {20042104,"zhou",67.0,79.0,98.0},
                {20042105,"wu",91.0,97.0,98.0},
                {20042106,"zheng",64.0,98.0,84.0}};


    int i;
        for(i=0;i<7;i++)                           
        {
                stu.score[3]=stu.score[0]+stu.score[1]+stu.score[2];
            printf("%d",stu.score[3]);
        }printf("\n");
   int x;                                    
   int y;
   float temp;
   for(y=7;y>0;y--)
   {
     for(x=1;x<y;x++)
         {
        if((stu.score[3])>(stu[i+1].score[3]))
                {
          temp=(stu.score[3]);
          (stu.score[3])=(stu[i+1].score[3]);
          (stu[i+1].score[3])=temp;
                }
         }
   }
   int j;                                    
   for(j=0;j<=6;j++)  printf("%d",stu[j].score[3]);printf("\n");
   return 0;
}


[ 本帖最后由 bjbitren 于 2007-3-25 20:11 编辑 ]
2007-3-25 20:08#1
查看资料  Blog  发短消息  QQ  顶部
 
junhu33
小水手
Rank: 1



UID 29894
精华 0
积分 8
帖子 8
阅读权限 10
注册 2007-4-5
状态 离线
自己看下面代码:是没问题的:
/*struct*/
#include <stdio.h>
main()
{
struct student                         /*定义结构体并初始化*/
{
        int num;
        char name[20];
        float score[4];
}stu[7]={{20042100,"zhang",12.0,13.0,14.0},
                {20042101,"wang",65.5,45.5,76.0},
                {20042102,"li",76.0,35.0,87.0},
                {20042103,"zhao",89.0,65.0,76.0},
                {20042104,"zhou",67.0,79.0,98.0},
                {20042105,"wu",91.0,97.0,98.0},
                {20042106,"zheng",64.0,98.0,84.0}};


    int i;
        for(i=0;i<7;i++)                           
        {
                stu.score[3]=stu.score[0]+stu.score[1]+stu.score[2];
            printf("%f\n",stu.score[3]);
        }printf("\n");
   int x;                                    
   int y;
   float temp;
   for(y=6;y>0;y--)
   {
     for(x=0;x<y;x++)
         {
        if((stu[y].score[3])>(stu[x].score[3]))
                {
          temp=(stu[y].score[3]);
          (stu[y].score[3])=(stu[x].score[3]);
          (stu[x].score[3])=temp;
                }
         }
   }
   int j;                                    
   for(j=0;j<=6;j++)  printf("%f\n",stu[j].score[3]);printf("\n");
   return 0;
}
2007-4-5 16:47#2
查看资料  Blog  发短消息  顶部
 
junhu33
小水手
Rank: 1



UID 29894
精华 0
积分 8
帖子 8
阅读权限 10
注册 2007-4-5
状态 离线
/*struct*/
#include <stdio.h>
main()
{
struct student                         /*定义结构体并初始化*/
{
        int num;
        char name[20];
        float score[4];
}stu[7]={{20042100,"zhang",12.0,13.0,14.0},
                {20042101,"wang",65.5,45.5,76.0},
                {20042102,"li",76.0,35.0,87.0},
                {20042103,"zhao",89.0,65.0,76.0},
                {20042104,"zhou",67.0,79.0,98.0},
                {20042105,"wu",91.0,97.0,98.0},
                {20042106,"zheng",64.0,98.0,84.0}};


    int i;
        for(i=0;i<7;i++)                           
        {
                stu.score[3]=stu.score[0]+stu.score[1]+stu.score[2];
            printf("%f\n",stu.score[3]);
        }printf("\n");
   int x;                                    
   int y;
   float temp;
   for(y=6;y>0;y--)
   {
     for(x=0;x<y;x++)
         {
        if((stu[y].score[3])>(stu[x].score[3]))
                {
          temp=(stu[y].score[3]);
          (stu[y].score[3])=(stu[x].score[3]);
          (stu[x].score[3])=temp;
                }
         }
   }
   int j;                                    
   for(j=0;j<=6;j++)  printf("%f\n",stu[j].score[3]);printf("\n");
   return 0;
}
2007-4-5 16:49#3
查看资料  Blog  发短消息  顶部
     


  可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题  


 


所有时间为 GMT+8, 现在时间是 2008-12-2 01:43 Powered by Discuz! 4.1.0 清除 Cookies - XiaoHui.Net 笑汇程序员论坛 - Archiver