菜鸟C替抄代码1

  • 我是小白,非科班的,编程爱好者,当娱乐看看

  • 今天为我外校大一学妹抄抄代码,反正我也不会。我能做的只是抄抄写写。

#include"stdio.h"
int main()
{
	int a, b, c;
	void swap(int* px, int* py);
	printf("Please input three numbers:");
	scanf("%d %d %d ", &a, &b, &c);
	if (a < b)
		swap(&a, &b);
	if (a < c)
		swap(&a, &c);
	if (b < c)
		swap(&b, &c);
	printf("the three numbers sorted from big to small:%d %d %d", a, b, c);
	
	return 0;
}
void swap(int* px, int* py)
{
	int temp;
	temp = *px;
	*px = *py;
	*py = temp;
}
#include"stdio.h"
int main()
{
	while (1)
	{
		int a[10] = {}, i;
		int* pmax, * pmin;
		void swap(int* npx, int* py);
		printf("please input 10 numbers:");
		for (i = 0; i < 10; i++)
		{
			scanf("%d", a + i);
		}
		pmax = a;
		pmin = a;

		for (i = 1; i < 10; i++)
		{
			if (*pmax < a[i])
				pmax = &a[i];
			if (*pmin > a[i])
				pmin = &a[i];
		}
		swap(pmax, &a[9]);
		swap(pmin, &a[0]);
		printf("After swap the ten words,numbers are:\n");
		for (i = 0; i < 10; i++)
		{
			printf("%d\t", a[i]);
		}
		printf("\n");

	}
	
	return 0;
}
void swap(int* px, int* py)
{
	int temp;
	temp = *px;
	*px = *py;
	*py = temp;
}

去睡觉了,明天过来画图哈哈哈

c
116 views
Comments
登录后评论
Sign In
·

不懂为什么要抄写代码,这里说的抄写是指从书上对着打到电脑上吗?