题解 | #Zero-complexity Tran...#

Zero-complexity Transposition

https://www.nowcoder.com/practice/c54775799f634c72b447ef31eb36e975

#include <iostream>
#include<stack>
using namespace std;

int main() {
    stack<long long> stack1;
    int Number = 0;
    while (scanf("%d", &Number) !=
            EOF) { //此处必须写上“!=EOF”,否则会超时!
        for (int i = 0; i < Number; i++) {
            long long number;
            scanf("%lld", &number);
            stack1.push(number);
        }
        for (int i = 0; i < Number; i++)  {
            printf("%lld ", stack1.top()); //先读顶部元素
            stack1.pop();//再出栈

        }
        printf("\n");
    }
}

全部评论

相关推荐

牛客279957775号:铁暗恋
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务