1.A
2.输出:6 2 3 4 5
3.D
4.5,即是a[3]
5.D
6.000000000062FDF0,000000000062FDF0,000000000062FDF0,000000000062FE14,19,1
前四项%p是输出地址,*p+9是先运算*p,因*p指向a数组第零项故*p=10,再运算加9,最后结果是19,*(p+9) = a[9]=1
7.
#include<stdio.h>
double Swap(double x,double y);
int main(){
double a = 5.0,b = 9.0;
Swap(a,b);
printf("a=%f,b=%f",a,b);
return 0;
}
double Swap(double x,double y){
double temp;
temp = x;
x = y;
y = temp;
}
#include<stdio.h>
double Swap(double *x,double *y);
int main(){
double a = 5.0,b = 9.0;
Swap(&a,&b);
printf("a=%f,b=%f",a,b);
return 0;
}
double Swap(double *x,double *y){
double temp;
temp = *x;
*x = *y;
*y = temp;
}
8.
#include<stdio.h>
#define N 5
void bubble_sort(double *p,int sz)
{
int i,j;
for (i = 0; i < sz-1; i++)
{
for ( j = 0; j <sz-1-i; j++)
{
if (*(p + j) > *(p + j + 1))
{
double temp = *(p + j);
*(p + j) = *(p + j + 1);
*(p + j + 1) = temp;
}
}
}
}
int main()
{
double arr[N];
int i;
for(i=0;i<N;i++){
scanf("%lf",&arr[i]);
}
bubble_sort(arr,N);
for (i = 0; i < N; i++)
{
printf("%.2f ", arr[i]);
}
return 0;
}