每日一九度之 题目1039:Zero-complexity Transposition

时间限制:1 秒

内存限制:32 兆

特殊判题:

提交:3372

解决:1392

<dl> <dt> 题目描述: </dt> <dd>

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.

</dd> </dl> <dl> <dt> 输入: </dt> <dd>

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).

</dd> </dl> <dl> <dt> 输出: </dt> <dd>

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

</dd> </dl> <dl> <dt> 样例输入: </dt> <dd>
5
-3 4 6 -8 9
</dd> </dl> <dl> <dt> 样例输出: </dt> <dd>
9 -8 6 4 -3
</dd> </dl>

水题,但是因为是英文,出了一点小(不)问(认)题(识)。

本来认为是绝对值排序,但是后来仔细一看,原来就只是把数组反过来输出就好了。

看懂题目很重要。。是的,真的很重要!

这是不改变数组,直接反过来输出的。

//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;
}

 

全部评论

相关推荐

程序员花海:实习和校招简历正确格式应该是教育背景+实习+项目经历+个人评价 其中项目经历注意要体现业务 实习经历里面的业务更是要自圆其说 简历模板尽可能保持干净整洁 不要太花哨的
点赞 评论 收藏
分享
面试官全程关摄像头1.自我介绍一下2.React和Vue哪个更熟悉一点3.你在之前那段实习经历中有没有什么技术性的突破(我只是实习了44天工作28天,我把我能说的都说了)4.你封装的哪个表单组件支不支持动态传值5.自己在实习阶段Vue3项目封装过hook吗6.hook有什么作用7.Vue2和Vue3的响应式区别(我说一个是proxy是拦截所有的底层操作,Object.defineProperty本身就是一个底层操作,有些东西拦截不了,比如数组的一些操作还有等等,面试官就说实在要拦截能不能拦截????我心想肯定不行呀,他的底层机制就不允许吧)8.pinia和vuex的区别(这个回答不出来是我太久没用了)9.pinia和zustand的区别,怎么选(直接给我干懵了)(我说react能用pinia吗&nbsp;&nbsp;他说要用的话也可以)10.渲染一万条数据,怎么解决页面卡顿问题(我说分页、监听滚轮动态加载,纯数据展示好像还可以用canvas画)(估计是没说虚拟表单,感觉不满意)11.type和interface的区别12.ts的泛型有哪些作用(我就说了一个结构相同但是类型不同的时候可以用,比如请求响应的接口,每次的data不同,这里能用一个泛型,他问我还有什么)13.你项目用的是React,如果让你再写一遍你会选择什么14.pnpm、npm、yarn的区别15.dependencies和devdependencies的区别总而言之太久没面试了,上一段实习的面试js问了很多。结果这次js一点没问,网络方面也没考,表现得很一般,但是知道自己的问题了&nbsp;&nbsp;好好准备,等待明天的影石360和周四的腾讯了&nbsp;&nbsp;加油!!!
解zj:大三的第一段面试居然是这样的结局
查看15道真题和解析
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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