回覆列表
-
1 # 掉眼淚的冠軍
-
2 # 微笑的水歲月薄荷微
程式碼如下:
#include?
int?main()
{
int?a[10],*p1,*p2,x,i;
for(p1=a;p1
scanf("%d",p1);
for(p1=a,p2=&a[9];p1
{
x=*p1;
*p1=*p2;
*p2=x;
}
p1?=?a?;
for(i=0;i
printf("%d",*(p1+i));
return?0;
}輸出結果如下:
# include <stdio.h>int main (void){printf("請輸入數字,數字中間以空格隔開。\n");int a[10];char ch;int j = 0;for (int k = 0 ; k < 10 ; k++){scanf("%d%c" , &a[k] , &ch);j++;//儲存一共輸入了幾個數字if (ch == "\n")break;}int m = 0;int n = j - 1;int p;while (m < n){p = a[m];a[m] = a[n];a[n] = p;m++;n--;}printf("所輸入的陣列倒序為:\n");for(k = 0 ; k < j ; k++)printf("%d " , a[k]);printf("\n");return 0;}