题解 | 牛牛的书

牛牛的书

https://www.nowcoder.com/practice/30bb969e117b4f6d934d4b60a2af7489

#include<stdio.h>
struct book
{
    char name[100];
    int price;
}a[100];

int main()
{
int n;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
    scanf("%s %d",a[i].name,&a[i].price);
    
    
}
for(int i=0;i<n;i++)
{
    for(int j=i;j<n;j++)
    {
        if(a[i].price>=a[j].price)
        {
            struct book temp;
            temp=a[i];
            a[i]=a[j];
            a[j]=temp;
        }
    }
}
for(int i=0;i<n;i++)
{
    printf("%s\n",a[i].name);
}


}

全部评论

相关推荐

点赞 评论 收藏
分享
最喜欢秋天的火龙果很...:第一份工作一定要往大的去,工资低点没事。后面换工作会更好找,即使你去小公司,你也不可能不会换工作的。所以找大的去
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务