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);
     }
     }

  • 相关阅读:
    “#ifdef __cplusplus extern "C" { #endif”的定义
    【原创】分布式之redis复习精讲
    python爬虫入门(六) Scrapy框架之原理介绍
    PYTHON面试
    14.Ubuntu基本命令
    python爬虫入门(五)Selenium模拟用户操作
    python爬虫入门(四)利用多线程爬虫
    python爬虫入门(三)XPATH和BeautifulSoup4
    python爬虫入门(一)urllib和urllib2
    7.Ajax
  • 原文地址:https://www.cnblogs.com/jiafangfang/p/6062209.html
Copyright © 2011-2022 走看看