[九度OJ]: 1039 Zero-complexity Transposition

来源:互联网 发布:手机养成游戏知乎 编辑:程序博客网 时间:2024/05/02 21:05

最近开始刷题了,打算先把九度OJ刷个遍吧,就从这道题开始吧。我身上的担子很重,根本不能停歇

这道题很简单,就是问一个很长的数组如何反序输出。
通过代码如下:

注意申明是长数组型
还有一种方法用String数组存储也可以

#include <iostream>using namespace std;int main(){    int n;    while (cin >> n){        long long int a[10000];        for (int i = 0; i < n; i++){            cin >> a[i];        }        for (int i = n - 1; i >= 0; i--){            cout << a[i];            if (i == 0){                cout << endl;            }            else{                cout << " ";            }        }    }    return  0;}
0 0
原创粉丝点击