View Code of Problem 76

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

Double click to view unformatted code.


Back to problem 76