码迷,mamicode.com
首页 > 其他好文 > 详细

抄写作业

时间:2017-04-10 10:43:11      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:log   name   core   float   code   after   int   color   second   

#include<stdio.h>
struct student
{
    int num;
    char name[20];
    float score;
};
int main()
{
    struct student stu[5]={{10101,"lili",78},{10103,"gygy",98.5},{10106,"fttf",86},{10108,"bbhh",73},{10110,"huhu",100}};
    struct student temp;
    int n=5;
    int i,j,k;
    printf("the order is:\n");
    for(i=0;i<n-1;i++)
    {k=i;
    for(j=i+1;j<n;j++)
    if(stu[j].score>stu[k].score)
    k=j;
    temp=stu[k];stu[k]=stu[i];stu[i]=temp;
    }
    for(i=0;i<n;i++)
    printf("%d\n,%s\n,%f\n",stu[i].num,stu[i].name,stu[i].score);
    return 0;
}
复制代码
the order is: 10110 ,huhu ,100.000000 10103 ,gygy ,98.500000 10106 ,fttf ,86.000000 10101 ,lili ,78.000000 10108 ,bbhh ,73.000000

-------------------------------- Process exited after 0.203 seconds with return value 0 请按任意键继续. . .

 

9.5

复制代码
#include<stdio.h>
#include<string.h>
int main()
{struct student
     long num;
     char name[20];
     char sex;
     float score;
};
struct student stu_1={10101,"Li Lin",M,89.5};
struct student *p;
p=&stu_1;
printf("%d\n,%s\n,%c\n",stu_1.num,,stu_1.name,stu_1.sex,stu_1.score);
printf("%d\n,%s\n,%c\n",stu_1.num,,stu_1.name,stu_1.sex,stu_1.score);
return 0;
}

 

抄写作业

标签:log   name   core   float   code   after   int   color   second   

原文地址:http://www.cnblogs.com/zxg99/p/6687768.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!