当前位置: 首页 > news >正文

[保研/考研机试] KY109 Zero-complexity Transposition 上海交通大学复试上机题 C++实现

描述:

You are given a sequence of integer numbers. Zero-complexity transposition of the sequence is the reverse of this sequence. Your task is to write a program that prints zero-complexity transposition of the given sequence.

输入描述:

For each case, the first line of the input file contains one integer n-length of the sequence (0 < n ≤ 10 000). The second line contains n integers numbers-a1, a2, …, an (-1 000 000 000 000 000 ≤ ai ≤ 1 000 000 000 000 000).

输出描述:

For each case, on the first line of the output file print the sequence in the reverse order.

示例1:

输入:
5
-3 4 6 -8 9输出:
9 -8 6 4 -3

源代码:

#include<iostream>
#include<stack>
using namespace std;//例题5.4 Zero-complexity Transposition
int main()
{int n;cin >> n;stack<int> myStack;for (int i = 0; i < n; i++) {int temp = 0;cin >> temp;myStack.push(temp);}cout << myStack.top();myStack.pop();while (!myStack.empty()) {cout << " " << myStack.top();myStack.pop();}cout << endl;return 0;
}
// 64 位输出请用 printf("%lld")

提交结果:

 

http://www.lryc.cn/news/123556.html

相关文章:

  • Linux零基础快速入门到精通
  • ARM02汇编指令
  • 从初学者到专家:Java方法的完整指南
  • 【生成式AI】ProlificDreamer论文阅读
  • C++元编程——模拟javascript异步执行
  • 【JavaEE】懒人的福音-MyBatis框架—复杂的操作-动态SQL
  • Springboot 默认路径说明
  • springboot注册拦截器与返回统一标准响应格式
  • 卷王特斯拉又全网降价了,卷死车企们
  • wiley:revision 流程
  • 【论文阅读】基于深度学习的时序预测——Pyraformer
  • 玩转IndexedDB,比localStorage、cookie还要强大的网页端本地缓存
  • RedisDesktopManager连不上redis问题解决(小白版)
  • 蓝帽杯 取证2022
  • MyBatis and or使用列表控制or条件
  • C语言刷题训练【第11天】
  • 正则表达式的使用
  • PHP 求解两字符串所有公共子序列及最长公共子序列 支持多字节字符串
  • linux内核bitmap之setbit汇编实现
  • Golang设计模式
  • leetcode151. 反转字符串中的单词
  • 【BASH】回顾与知识点梳理(十七)
  • 时序预测-Informer简介
  • 2023牛客第七场补题报告C F L M
  • Android使用kotlin+协程+room数据库的简单应用
  • Kubernetes pod调度约束[亲和性 污点] 生命阶段 排障手段
  • Matlab实现模拟退火算法(附上多个完整源码)
  • 前后端分离------后端创建笔记(03)前后端对接(上)
  • stable diffusion安装包和超火使用文档及提示词,数字人网址
  • 训练营:贪心篇