每日一九度之 题目1039:Zero-complexity Transposition
时间限制:1 秒
内存限制:32 兆
特殊判题:否
提交:3372
解决:1392
- 题目描述:
-
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.
- 样例输入:
-
5 -3 4 6 -8 9
- 样例输出:
-
9 -8 6 4 -3
水题,但是因为是英文,出了一点小(不)问(认)题(识)。
本来认为是绝对值排序,但是后来仔细一看,原来就只是把数组反过来输出就好了。
看懂题目很重要。。是的,真的很重要!
这是不改变数组,直接反过来输出的。
//Asimple #include <iostream> #include <algorithm> #include <cstring> #include <cstdio> #include <cctype> #include <cstdlib> #include <stack> #include <cmath> #include <map> #include <string> #include <queue> #define INF 100000 using namespace std; const int maxn = 10005; typedef long long ll; int n, m; ll a[maxn]; int main(){ while( ~scanf("%d", &n) ){ for(int i=0; i<n; i++){ scanf("%ld",&a[i]); } for(int i=n-1; i>=0; i--){ printf(i==0?"%ld\n":"%ld ",a[i]); } } return 0; }
做了一点小处理,将数组反了过来。
//Asimple #include <iostream> #include <algorithm> #include <cstring> #include <cstdio> #include <cctype> #include <cstdlib> #include <stack> #include <cmath> #include <map> #include <string> #include <queue> #define INF 100000 using namespace std; const int maxn = 10005; typedef long long ll; int n, m; ll a[maxn]; int main(){ while( ~scanf("%d", &n) ){ for(int i=0; i<n; i++){ scanf("%ld",&a[i]); } for(int i=0; i<n/2; i++){ ll temp = a[i]; a[i] = a[n-1-i]; a[n-1-i] = temp; } for(int i=0; i<n; i++){ printf(i==n-1?"%ld\n":"%ld ",a[i]); } } return 0; }
低调做人,高调做事。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~