时光如水,总是无言。若你安好,便是晴天。

二维数组按某列排序交换元素

二维数组按某列排序需要交换各个列的元素;此时利用结构体数组比较方便,结构体数组可以直接交换,里面的各个成员就i能交换了。

#include "stdio.h"
#include "stdlib.h"
void main() {
    struct student
    {
        int age;
        float score;
    };
    struct student a, b;
    a.age = 10; a.score = 100;
    b.age = 11; b.score = 99;
    struct student c;
    c = a;
    a = b;
    b = c;
    printf("a:%d %f\n", a.age, a.score);
    printf("b:%d %f\n", b.age, b.score);
    system("pause");
}

 

 

posted @ 2018-11-11 23:17  OceanWaves  阅读(196)  评论(0)    收藏  举报
/* 看板娘 */ /* 粒子吸附*/