展开全部
收起
5回答
提交回答
  • 至过去的我

    2044人对此回答表示赞同

    我是未来的你,你现在是不是在年找寻小程序答案。你不要感觉诧异,给你来信原因,就是让你不在后悔。今天去学习如何推广小程序,相信......点击查看更多>
    发布于
  • 柠檬蛋挞

    42人对此回答表示赞同

    乱七八糟,修改如下:

    #include<stdio.h>
    struct student
    {
    long num[10];
    char name[10];
    float score[3],av,al;
    };

    void max(struct student stu[10])
    {
    struct student stud;
    int i,j;

    for(i=0;i<10;i++)
    {
    for(j=10-i-1;j>0;j--)
    {
    if(stu[j].al>stu[j-1].al)
    {
    stud=stu[j];
    stu[j]=stu[j-1];
    stu[j-1]=stud;
    }
    }
    }
    }

    void main()
    {
    struct student stu[10];
    int i,j,k;

    for(i=0;i<10;i++)
    {
    printf("please input %d student's num name score:\n",i+1);
    scanf("%s%s%f%f%f",&stu[i].num,&stu[i].name,
    &stu[i].score[0],stu[i].score[1],stu[i].score[2]);
    stu[i].al=stu[i].score[0]+ stu[i].score[1]+ stu[i].score[2];
    stu[i].av=stu[i].al/3;
    }

    max(stu);

    for(k=0;k<10;k++)
    {
    printf("%d \t %s \t %s \t %f \t %f \t %f \t %f \t %f\n",k+1,
    stu[k].num,stu[k].name,stu[k].score[0],
    stu[k].score[1],stu[k].score[2],
    stu[k].av,stu[k].al);
    }
    }
    展开
    42
    0回复
    发布于 7年前

    评论(0)

    收起评论

  • Adeline

    42人对此回答表示赞同

    5年没有看过程序了,唉.我随便看看,有不对的地方,批评指正..错误还真是多....

    1\max函数没有{ }..
    2\float score[3],不是只有3科成绩吗?怎么多了一个?不要浪费内存.呵呵,这是静态数组啊.
    3\float max(float u[10]);定义是有问题.应该是void max(float u[])
    float max(),你怎么去return个float出来,有什么用?
    4\结构体的使用错了
    struct student
    {
    char stu[10];
    float m[10];
    }
    应该是:student stu[10];吧?
    5\大哥.你的s[i]=all;s[]在哪定义的?要在前面定义一下float s[10].(实际上9就行了,才10个学生 )
    6\max的使用错了.应该直接是 max(s[]).麻烦你告诉我m[10]=max(s[10])这个是什么意思,吐血.你的意思是想复制一个数组.可是数组是这样复制的吗?在C里只能用循环一个一个来.在C++里才可以重载.再说,你这一句的实际意思我想你也看到出来吧?是把S数据的最后一个数复制到m数组的最后一个数.如果你写成m=s,我也说你有点对,这时m跟s就是同一个数组了,改哪个,两个都改,相当于两个指针指向同一个数组...啊,好像说远了.m[10]在这里是多余的,没什么用.
    7\最后的打印看不下去了.不用看都知道是没用的.你最少一个数组来记录每个学生的学号跟对应的名次吧?最好是用一个结构体来记录.这就好像是数据库里的数据表设计一样了.

    我也不知道对不对,凭记忆吧,打了半个小时字.呵.
    展开
    42
    0回复
    发布于 7年前

    评论(0)

    收起评论

  • Roberto一帆

    42人对此回答表示赞同

    float max(float u[10])是不是想写成一个选择排序算法的函数?怎么没有花括号并且后面还有分号?主函数乱七八糟的,你还是先整理整理把
    展开
    42
    0回复
    发布于 7年前

    评论(0)

    收起评论

  • Leo

    42人对此回答表示赞同

    你先让语法对了啊,float max(float u[10]); 是什么意思?我看不懂,C语言语法里没这一条吧。
    展开
    42
    0回复
    发布于 8年前

    评论(0)

    收起评论

  • 江振宇

    42人对此回答表示赞同


    改好了。

    如果分数带小数点时这个比较:
    m[j]==stu[k].all 会有问题。

    #include<stdio.h>

    struct student
    {
    long num;
    char name[10];
    float score[3],av,all;
    };

    void max(float u[10])
    {
    int i,j;
    float k;
    for(i=0;i<9;i++)
    {
    for(j=i+1;j<10;j++)
    if(u[j]>u[i]) {k=u[i];u[i]=u[j];u[j]=k;}
    }
    }

    void main()
    {
    int i,j,k;
    struct student stu[10];
    float m[10],s[10];
    float all,av;

    for(i=0;i<10;i++)
    {
    printf("please input %dstudent's num name score1 score2 score3\n",i);
    scanf("%ld %s %f %f %f",&stu[i].num,&stu[i].name,&stu[i].score[0],&stu[i].score[1],&stu[i].score[2] );
    stu[i].all=stu[i].score[0]+ stu[i].score[1]+ stu[i].score[2];
    stu[i].av = stu[i].all/3;
    s[i]=stu[i].all;
    }

    (void) max(s);
    for (i=0;i<10;i++) m[i] = s[i];

    for(j=0;j<10;j++)
    {for(k=0;k<10;k++)
    if(m[j]==stu[k].all)
    printf("%d %ld %s %f %f %f %f %f \n",j,stu[k].num,stu[k].name,stu[k].score[0], stu[k].score[1],stu[k].score[2],stu[k].av,stu[k].all);
    }}

    输入数据:
    1 L1 100 90 63
    2 L2 90 30 40
    3 L3 80 38 46
    4 L4 75 66 77
    5 L5 83 99 34
    6 L6 63 55 66
    7 L7 77 66 77
    8 L8 88 77 33
    9 L9 99 33 22
    10 L10 55 55 66
    输出正确

    0 1 L1 100.000000 90.000000 63.000000 84.333336 253.000000
    1 7 L7 77.000000 66.000000 77.000000 73.333336 220.000000
    2 4 L4 75.000000 66.000000 77.000000 72.666664 218.000000
    3 5 L5 83.000000 99.000000 34.000000 72.000000 216.000000
    4 8 L8 88.000000 77.000000 33.000000 66.000000 198.000000
    5 6 L6 63.000000 55.000000 66.000000 61.333332 184.000000
    6 10 L10 55.000000 55.000000 66.000000 58.666668 176.000000
    7 3 L3 80.000000 38.000000 46.000000 54.666668 164.000000
    8 2 L2 90.000000 30.000000 40.000000 53.333332 160.000000
    9 9 L9 99.000000 33.000000 22.000000 51.333332 154.000000
    展开
    42
    0回复
    发布于 9年前

    评论(0)

    收起评论

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
咨询热线

13312967497

扫码添加业务即可随时咨询 还可领取小程序推广攻略

业务咨询: 13312967497
扫码咨询

扫码咨询套餐

回到顶部