题目
1.证明P++等价于(p)++还是等价于*(p++)?
#include <stdio.h>
int main()
{
int a=5;
int *p=&a;
printf("p=%d\n",p); //p=6487620
printf("p++=%d\n",p++); //p++=6487620
p=&a;
printf("(p)++=%d\n",(p)++); //(p)++=6487620
printf("*(p++)=%d\n",*(p++)); //*(p++)=6487628
}
2 题目6-1 计算两数的和与差
(1) 实验代码
#include<stdio.h>
void sum_diff( float op1, float op2, float *psum, float *pdiff );
int main()
{
float a, b, sum, diff;
scanf("%f %f", &a, &b);
sum_diff(a, b, &sum, &diff);
printf("The sum is %.2f\nThe diff is %.2f\n", sum, diff);
return 0;
}
void sum_diff( float op1, float op2, float *psum, float *pdiff )
{
*psum=op1+op2;
*pdiff=op1-op2;
}
(2) 设计思路