第七周作业Mr.Yang

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;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值