程序填空,以下程序将数组中的数据按逆序存放。

程序填空,以下程序将数组中的数据按逆序存放。,第1张

#include<stdio.h>

#define SIZE 12

int main()

{

int a[SIZE],i,j,t

for(i=0i<SIZEi++)

scanf("%d",&a[i])

i=0

j=SIZE-1

while(i<j)

{

t=a[i]

a[i]=a[j]

a[j]=t

i++

j--

}

for(i=0i<SIZEi++)

printf("%4d",a[i])

printf("\n")

return 0

}

1 2 3 4 5 6 7 8 9 5 6 4

4 6 5 9 8 7 6 5 4 3 2 1

--------------------------------

Process exited after 17.51 seconds with return value 0

请按任意键继续. . .

invert(int x[], int n)

{

    int *p = x, *q = x + (n - 1)

    int tmp

    for ( p < q ++p, --q)

    {

        tmp = *p

        *p = *q

        *q = tmp

    }

}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/11180232.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-14
下一篇 2023-05-14

发表评论

登录后才能评论

评论列表(0条)

保存