zzuli 1812: sort 排序
发布日期:2021-05-09 04:20:34 浏览次数:22 分类:博客文章

本文共 920 字,大约阅读时间需要 3 分钟。

1812: sort

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 352  Solved: 216

Description

想必大家对排序已经很熟悉了,但是spy好像对排序不太熟悉,有一天,他看到这样一个关于排序的题目:

对于 k 个用空格分隔开的整数,依次为 n1, n2 … nk。请将所有下标不能被 3 但可以被 2 整除的数在这些数字原有的位置上进行升序排列,此外,将余下下标能被 3 整除的数在这些数字原有的位置上进行降序排列。

spy想了半天不知道怎么排序,你可以帮助他么?

Input

多组数据,每组数据一行,为k个小于1000的正整数,依次为 n1, n2 … nk。(1 <= k <= 100000)

Output

对于每组数据,输出排序后的结果。

Sample Input

1 3 4 2 10 6 8

Sample Output

1 2 6 3 10 4 8

代码:

#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;const int maxn=100005;struct node { int num; int pos; int flag; node () { flag=0; }}ans[maxn];int bns[maxn],cns[maxn];bool cmpbns(const int &a, const int &b) { return a
b;}int main() { int index,bnspos,cnspos;bnspos=cnspos=0;index=1; while(~scanf("%d",&ans[index++].num)) { while(getchar()!='\n') { scanf("%d",&ans[index++].num); } for(int i=1;i

上一篇:zzuli 1815: easy problem 打表
下一篇:zzuli 1817: match number 模拟

发表评论

最新留言

网站不错 人气很旺了 加油
[***.192.178.218]2025年04月05日 03时52分10秒