ios开发之c语言基础-高级指针题目

//

//  main.m

//  C9-高级指针作业

//

//  Created by dllo on 15/10/16.

//  Copyright (c) 2015 dllo. All rights reserved.

//


#import <Foundation/Foundation.h>

#import "作业.h"

#define PI 3.14

#define AREA(r) PI * r * r

#define AVG(a,b) (a + b) / 2.0


int main(int argc, const char * argv[]) {

//    《第九讲:高级指针》

//    课后题:

//    1. (**)写一个函数交换两个结构体变量

//    2. (**)有一学生数组写一函数打印出指定分数段的学生信息

//    3. (**)有一学生数组,包含5个学生,写一个函数,对学生排序(按学号从小到大),使用结构体指针操作数组元素

//    4. (**)有一学生数组,包含5个学生,写一个函数,对学生排序(按姓名从小到大),使用结构体指针操作数组元素

//    5. (**)有一学生数组,包含5个学生,写一个函数,对学生排序(按分数从小到大),使用结构体指针操作数组元素

//    6. (**)定义一个求圆面积的宏

//    7. (**)定义一个求2个数平均数的宏

//1

//    jiegou a = {3};

//    student b = {4};

//    printf("%d%d",a.x, b.y);

//    jiegou *p = &a;

//    student *p2 = &b;

        //结构体指针做函数参数

//    change( p, p2);

//    printf("%d%d",a.x, b.y);

        //结构体做函数参数

//    exchange(a, b);

//    printf("%d%d",a.x, b.y);

    //结构体数组做函数参数

//    jiegou c[4] = {{3},{4},{4}};

//    student d[4] ={{5},{6},{7}};

//    threechage(c, d);

//    printf("%d%d",c[1].x, d[1].y);

//    //结构体数组指针做函数参数

//    jiegou *p3 = c;

//    student *p4 = d;

//    fourchage(p3, p4);

//    printf("%d%d",c[1].x, d[1].y);

    

    //2

    

//    student atu[5] = {

//        {"yuhao", 'm', 167, 89},

//        {"yuhdao", 'm', 112, 39},

//        {"yhao", 'm', 122, 19},

//        {"yuho", 'm', 132, 79},

//        {"yusao", 'm', 142, 59}

//    };

    //sortstu(atu, 5);

//    student *p = atu;

//    sortstu(p, 5);

//    //通过结构体数组实现和结构体数组指针实现

    

    //3

//    student atu[5] = {

//                {"yuhao", 'm', 167, 89},

//                {"yuhdao", 'm', 112, 39},

//                {"yhao", 'm', 122, 19},

//                {"yuho", 'm', 132, 79},

//                {"yusao", 'm', 142, 59}

//            };

//    student *p1 = atu;

//    

//    sortnumberstu(p1, 5);

//    printfstu(p1,5);

    

    //4

//    student atu[5] = {

//                        {"yuhao", 'm', 167, 89},

//                        {"yuhdao", 'm', 112, 39},

//                        {"zhao", 'm', 122, 19},

//                        {"suho", 'm', 132, 79},

//                        {"dusao", 'm', 142, 59}

//                    };

//    student *p2 = atu;

//    sortnamestu(p2, 5);

//    printfstu(p2,5);

    //5

//    student atu[5] = {

//                         {"yuhao", 'm', 167, 89},

//                         {"yuhdao", 'm', 112, 39},

//                         {"zhao", 'm', 122, 19},

//                         {"suho", 'm', 132, 79},

//                         {"dusao", 'm', 142, 59}

//                            };

//    

//    student *p3 =atu;

//    sortscorestu(p3, 5);

//    printfstu(p3, 5);

    //6

//    printf("%f", AREA(3));

//    printf("%f", AVG(5, 6));

    return 0;

}


原文地址:https://www.cnblogs.com/yuhaojishuboke/p/5043130.html