| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 949 人关注过本帖
标题:求助大佬,看下哪里错了
取消只看楼主 加入收藏
dydmd
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2018-11-1
结帖率:0
收藏
已结贴  问题点数:20 回复次数:0 
求助大佬,看下哪里错了
#include <stdio.h>
#include <stdlib.h>
void read(long num[],int score[],int n);
void av(int score[],int n);
void scoredes(long num[],int score[],int n);
void swap(int *x,int *y);
void swapnum(long *x,long *y);
int main()
{
    int order,n;
    int score[30];
    long num[30];
    printf("1.Input record\n");
    printf("2.Calculate total and average score of course\n");
    printf("3.Sort in descending order by score\n");
    printf("4.Sort in ascending order by number\n");
    printf("5.Search by number\n");
    printf("6.Statistic analysis\n");
    printf("7.List record\n");
    printf("0.Exit\n");

    while(1)
    {
        printf("Please enter your choice:\n");
        scanf("%d",&order);
        if(order==0)break;                                      //输入0时退出程序
        if(order==1)                                            //输入1时记录数据
          {
              printf("how many students?\n");
              scanf("%d",&n);
              read(num,score,n);
          }
        if(order==2)                                           //输入2时计算总分与平均分
            av(score,n);
        if(order==3)                                            //输入3时按成绩降序输出
            scoredes(num,score,n);


    }


    return 0;
}
void swap(int *x,int *y)//交换int型数
{
    int p;
    p=*x;
    *x=*y;
    *y=p;
}
void swapnum(long *x,long *y)//交换long型数
{
    long p;
    p=*x;
    *x=*y;
    *y=p;
}
void read(long num[],int score[],int n)//读入数据
{
    int i;

    for(i=0;i<n;i++)
    {
        printf("Input student's ID and score:");
        scanf("%ld%d",&num[i],&score[i]);

    }

}
void av(int score[],int n)//计算总分与平均分
{
    double x;
    int y=0,i;
    for(i=0;i<n;i++)
    {
        y+=score[i];
    }
    x=y/n;
    printf("sum is %d \naverage is %.2lf",y,x);
}
void scoredes(long num[],int score[],int n)//按成绩降序输出
{
    int i,j;
    for(i=0;i<n;i++)
    {
        for(j=n;j>i;j--)
        {
            if(score[j]<score[j-1])
            {
                swap(&score[j],&score[j-1]);
                swapnum(&num[j],&num[j-1]);
            }
        }
    }
    for(i=0;i<n;i++)
    {
        printf("%ld\t\t%d\n",num[i],score[i]);
    }
}






cb里显示||error: ld returned 1 exit status|
搜索更多相关主题的帖子: long num int score printf 
2018-11-01 23:04
快速回复:求助大佬,看下哪里错了
数据加载中...
 
   



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

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