ACM_编程与调试重点记录(十三)

1.如何通过指针返回多个值?

#include"stdio.h"

void swap(int *p1,int *p2)

{

       int p;

       p=*p1;*p1=*p2;*p2=p;

}

 

int main()

{

       int a=3,b=4;

       int *ptr1,*ptr2;

       ptr1=&a;ptr2=&b;

       if(a<b) swap(ptr1,ptr2);

       printf("%d  %d/n",a,b);

}

运行结果:

 

4  3

请按任意键继续. . .

 

2.请看:

坐标法

 

 

 

 

 

 

 

 

 

指针法

#include"stdio.h"

int main()

{

    struct w

    {

        int a;

        int b[100];

        double c[10];

    }e;

    printf("%d/n%d/n%d/n/n",sizeof(e.a),sizeof(e.b[0]),sizeof(e.c[0]));

    printf("%d/n%d/n%d/n%d/n",sizeof(e.a),sizeof(e.b),sizeof(e.c),sizeof(w));

}

运行结果:

 

4

4

8

 

4

400

80

488[GP1] 

请按任意键继续. . .

3.*&的作用与联系


 [GP1]为什么是488,而不是484呢???

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值