C 唔知應該邊度插code

2009-03-08 3:25 am

回答 (2)

2009-03-08 8:30 pm
✔ 最佳答案
#include <stdio.h>
#define MAX_SIZE 10

void reverseArray (int x[], int size);

int main(int argc, char *argv[])
{
int i;
int numPrinted;
int A[MAX_SIZE];
char ch;

for ( i=0; i<MAX_SIZE; i++)
A[i] = i;
for ( i=0; i<MAX_SIZE; i++) {
printf("%3d", A[i]);
}
printf("\n\n");

reverseArray (A, MAX_SIZE);

for ( i=0; i<MAX_SIZE; i++)
printf("%3d", A[i]);

printf("\nReversed Even nos.\n\n");
ch = getchar();
return 0;
}

void reverseArray (int x[], int size)
{
int i, j, temp;

for ( i=0, j=MAX_SIZE -1; i<j ; i++, j--)
temp = x[j];
x[j] = x[i];
x[i] = temp;
}
return;
}


The output will be:
2009-03-08 1:28 pm
You have received an answer at the cited link.


收錄日期: 2021-04-13 16:31:21
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20090307000051KK01678

檢視 Wayback Machine 備份