Description
将一维整型数组中的所有元素前移一个位置,下标为0的元素移到最后。
Input
输入仅一行,输入10个数,用空格隔开。
Output
输出仅一行,输出前移后的10个数,用空格隔开。
Sample Input
9 8 7 6 5 4 3 2 1 0
Sample Output
8 7 6 5 4 3 2 1 0 9
Source
#include <stdio.h>
int main()
{
int a[100],i,t;
for ( i = 0; i <10; i++)
{
scanf("%d",&a[i]);
}
t=a[0];
for ( i = 1; i <10; i++)
{
a[i-1]=a[i];
}
a[9]=t;
for ( i = 0; i <10; i++)
{
printf("%d ",a[i]);
}
system("pause");
return 0;
}