View Code of Problem 76

#include<stdio.h>
void main()
{
	int a[10] = {0};
	int k;
	for (int i = 0; i < 9; i++)
	{
		scanf("%d", &a[i]);
	}
	scanf("%d", &k);
	if (a[0] > a[8])//down
	{
		for (int i = 8; i >=0; i--)
		{
			if (a[i] < k)
			{
				a[i + 1] = a[i];
				a[i] = k;
			}
		}
	}
	if (a[0] < a[8])//up
	{
		for (int i = 8; i >= 0; i--)
		{
			if (a[i] > k)
			{
				a[i + 1] = a[i];
				a[i] = k;
			}
		}
	}
	for (int i = 0; i < 10; i++)
	{
		printf("%d\n", a[i]);
	}
}

Double click to view unformatted code.


Back to problem 76