[ create a new paste ] login | about

Link: http://codepad.org/QeE6s096    [ raw code | output | fork ]

C, pasted on Jul 14:
#include <stdio.h>
#define MAX 5

int
main(void)
{
	int             a[MAX] = {}, *p;

	while (p = a) {
		printf("正整数: ");
		scanf("%d", &a);
		if (*a == 0)
			break;
		while (*++p > 0);
		while (*--p > *a) {
			*(p + 1) = *p;
		}
		*(p + 1) = *a;
	}
	printf("入力された整数は小さい順に");
	printf("%d", *(p = a));
	while (*++p > 0)
		printf(", %d", *p);
	puts(" です.\n");

	return 0;
}


Output:
1
2
正整数: 入力された整数は小さい順に0 です.



Create a new paste based on this one


Comments: