回复 6楼 死蜜蜂
肯定不可以哦,每次都把a[5]提出了,再每个向后移一位
程序代码:/*
时间:2011年8月24日9:28:02
功能:输入6个数比如:1 4 7 3 5 2.可以得到
1 4 7 3 5 2
2 1 4 7 3 5
5 2 1 4 7 3
3 5 2 1 4 7
7 3 5 2 1 4
4 7 3 5 2 1
目的:论坛回复,练习数组的使用
*/
# include <stdio.h>
int main(void)
{
int a[6];
int i,j;
printf("请输入6个数字\n"); //输入6个数字
for (i=0; i<6; ++i)
scanf("%d",&a[i]);
printf("\n显示输出结果:\n");
for (j=0; j<6; ++j) //输出排列好的数组
{
for (i=6-j; i<6; ++i)
printf("%3d",a[i]);
for (i=0; i<6-j; ++i)
printf("%3d",a[i]);
printf("\n");
}
return 0;
}
/*
在VC++6.0中的输出结果为:
————————————
请输入6个数字
1
4
7
3
5
2
显示输出结果:
1 4 7 3 5 2
2 1 4 7 3 5
5 2 1 4 7 3
3 5 2 1 4 7
7 3 5 2 1 4
4 7 3 5 2 1
Press any key to continue
————————————
*/