close
輸入一些整數,逆序輸出到一行中。已知整數不超過一百個。
範例輸入:
1 2 3 4 5 6 7
範例輸出:
7 6 5 4 3 2 1
程式碼如下:
#include <stdio.h>
#define index 101
int main(int argc, const char * argv[]) {
int array[index], indexCount = 0, n;
while (scanf("%d", &n) != EOF)
{
array[indexCount++] = n;
}
for (int i = indexCount - 1; i >= 0; i--)
{
printf("%d ", array[i]);
}
return 0;
}
文章標籤
全站熱搜