zoukankan      html  css  js  c++  java
  • 铺垫一个 数据类型

    #include<stdio.h>
    struct student
    {
        int num;
        char name[20];
        float score;
    };
    int main()
    {
        int i,j;
        struct student stu[5],temp;
        for(i=0;i<5;i++)
        {
            scanf("%d%s%f",&stu[i].num,&stu[i].name,&stu[i].score);
        }
        for(i=0;i<4;i++)
        {
            for(j=0;j<4-i;j++)
            {
                if(stu[j].score>stu[j+1].score)
                {
                    temp=stu[j];
                    stu[j]=stu[j+1];
                    stu[j+1]=temp;
                }
            }
        }
        for(i=0;i<5;i++)
        {
            printf("%10d%10s%10.2f
    ",stu[i].num,stu[i].name,stu[i].score);
        }
        return 0;
    }

    这个  挺简单的   但是当时  不想看书   跳跃太大...看数据结构   也看不懂了.看来学习应该是 慢慢来 基础要  扎实

    #include<stdio.h>
    struct student
    {
        int num;
        char name[20];
        float score;
    };
    int main()
    {
        int i,j;
        struct student stu[5],temp,*p;
        for(p=stu,i=0;i<5;i++,p++)
        {
            scanf("%d%s%f",&p->num,&p->name,&p->score);
        }
        for(i=0;i<4;i++)
        {
            for(j=0;j<4-i;j++)
            {
                if(stu[j].score>stu[j+1].score)
                {
                    temp=stu[j];
                    stu[j]=stu[j+1];
                    stu[j+1]=temp;
                }
            }
        }
        for(p=stu,i=0;i<5;i++,p++)
        {
            printf("%10d%10s%10.2f
    ",p->num,p->name,p->score);
        }
        return 0;
    }

    测试数据:

    10101 zhang 78

    10103 wang 98.5

    10106 li 86

    10108 ling 78.5

    10110 sun 100

  • 相关阅读:
    【转载】分布式环境Raft一致性共识算法解读
    从码农到工程师:只要做到这6点
    产品思维的修炼–技术的必修课
    工具篇
    安全测试
    测试体会
    测试题目
    软件测试工具
    常见的性能测试方法
    性能测试在软件测试的周期位置
  • 原文地址:https://www.cnblogs.com/A-FM/p/5043219.html
Copyright © 2011-2022 走看看