zoukankan      html  css  js  c++  java
  • 排序

    #include<stdio.h>
    #include<string.h>
    struct Student{                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       
     char name[10];
     char sex[5];
     double grade; 
     };
     int main(void){
     struct Student student[10];
     int i,j;
     struct Student temp;
     for(i=0;i<10 ;i++){
      printf(" 请输入第%d个学生的信息: ",i+1);
      printf("姓名");
      char a[10];
      scanf("%s",&a);
      strcpy(student[i].name,a);
      printf(" 性别");
      char b[10];
      scanf("%s",&b);
      strcpy(student[i].sex,b);
      printf(" 成绩");
      scanf("%lf",&student[i].grade);
     }
     for(i=0;i<10;i++){
       for(j=i+1;j<10;j++){
       if(student[i].grade>student[j].grade){
       temp=student[i];
       student[i]=student[j];
       student[j]=temp;
       }
       }
     }
     for(i=0;i<10;i++){
     printf("%s %s %lf",student[i].name,student[i].sex,student[i].grade);
     }
     }

  • 相关阅读:
    汽车行业如何利用大数据
    汽车行业如何利用大数据
    Linux下Gcc 的编译过程
    第一个GraphX程序
    VC++ 模拟&quot;CLICK事件&quot;关闭指定窗体
    基于Canvas的Char.js库使用
    VELT-0.1.6开发:载入根文件系统
    HDU 5411 CRB and puzzle (Dp + 矩阵高速幂)
    JavaScript图片裁剪
    C++ string中的几个小陷阱,你掉进过吗?
  • 原文地址:https://www.cnblogs.com/jiafangfang/p/6062209.html
Copyright © 2011-2022 走看看