用户6619645841 2021-11-28 14:23 采纳率: 33.3%
浏览 13
已结题

请问一下为什么名字不跟着排序啊,真的看不出来了


#include <stdio.h>
#include <stdlib.h>

/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char *argv[]) 
{
    char cName[5][10]={"zhangsan","lisi","wangwu","zhaoliu","qianqi"};
    int a,b,temp,pos;
    float fScore[5]={55.0,79.0,88.0,98.0,66.0}; 
    
    printf("排序前:\n");
    for(a=0;a<5;a++)
    {
        printf("%s   %.2f\n",cName[a],fScore[a]);
    }
    
    printf("\n\n");
    
    printf("排序后:\n");
    
    for(a=0;a<4;a++)
    {
        temp=fScore[a];
        pos=a;
        
        for(b=a+1;b<5;b++)
        {
            if(fScore[b]>temp)
            {
                temp=fScore[b];
                pos=b;
            }
        } 
        
        fScore[pos]=fScore[a];
        fScore[a]=temp;
    }
    for(a=0;a<5;a++)
    {
        printf("%s  %.2f\n",cName[a],fScore[a]);
    }
    return 0;
        }
![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/209495080836121.png "#left")


  • 写回答

0条回答 默认 最新

    报告相同问题?

    问题事件

    • 系统已结题 12月6日
    • 创建了问题 11月28日

    悬赏问题

    • ¥15 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?