题解 | #Transposition#

Zero-complexity Transposition

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

#借用栈的思想,但要注意题目要求用long long类型,不过这道题用int也能对

#include "stdio.h"

#include "stack"

usingnamespacestd;

intmain(){

intn;longlongtemp;

stack<longlongmyStack;

while (scanf("%d",&n)!=EOF){

for (inti = 0i < n; ++i) {

scanf("%lld",&temp);

myStack.push(temp);

        }

while (!myStack.empty()){

printf("%lld ",myStack.top());

myStack.pop();

        }

    }

}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务