当前位置:网站首页>Rearrange array
Rearrange array
2022-07-04 15:35:00 【Zaltana】
Given a size of N Array of arr[], Each of these elements is in 0 To N- 1 Within the scope of . Rearrange the given array , send arr[i] Turn into arr[arr[i]]. such as arr[] = {4,0,2,1,3}, be arr[arr[0]] = arr[4]= 3, arr[arr[1]] =arr[0] = 4. Output new array .
Do not consider unreasonable input and other special circumstances .
Format .
Input format : On the first line, enter the length of the array N, The second line inputs the array elements , integer , The blank space to separate .
Output format : Output integer , The blank space to separate .
Examples
Input : 5
4 0 2 1 3
Output : 3 4 2 0 1
#include<bits/stdc++.h>
using namespace std;
int main( )
{
int A[100], B[100], N;
scanf("%d", &N);
for(int i=0;i<N;i++)
scanf("%d", &A[i]);
for(int i=0;i<N;i++)
B[i] = A[A[i]] ;
for(int i=0;i<N;i++)
printf("%d ", B[i]);
return 0;
}
边栏推荐
- PXE网络
- Neuf tendances et priorités du DPI en 2022
- mysql 联合主键_Mysql 创建联合主键[通俗易懂]
- Techsmith Camtasia Studio 2022.0.2屏幕录制软件
- LeetCode 58. 最后一个单词的长度
- 在芯片高度集成的今天,绝大多数都是CMOS器件
- Quelles sont les perspectives de l'Internet intelligent des objets (aiot) qui a explosé ces dernières années?
- Redis 發布和訂閱
- Deep learning network regularization
- 直播预告 | PostgreSQL 内核解读系列第二讲:PostgreSQL 体系结构
猜你喜欢
. Net applications consider x64 generation
Unity animation day05
Dry goods | fMRI standard reporting guidelines are fresh, come and increase your knowledge
[Dalian University of technology] information sharing of postgraduate entrance examination and re examination
Redis哨兵模式实现一主二从三哨兵
這幾年爆火的智能物聯網(AIoT),到底前景如何?
函数式接口,方法引用,Lambda实现的List集合排序小工具
Intelligent customer service track: Netease Qiyu and Weier technology play different ways
一篇文章搞懂Go语言中的Context
Redis 发布和订阅
随机推荐
Unity animation day05
How did the beyond concert 31 years ago get super clean and repaired?
An article learns variables in go language
Unity脚本生命周期 Day02
Enter the width!
Redis 發布和訂閱
Unity script API - transform transform
文本挖掘工具的介绍[通俗易懂]
找数字
What is the future of the booming intelligent Internet of things (aiot) in recent years?
Deep learning network regularization
Shell programming basics
宽度与对齐
在芯片高度集成的今天,绝大多数都是CMOS器件
Unity update process_ Principle of unity synergy
Unity script API - component component
Data Lake Governance: advantages, challenges and entry
hexadecimal
mysql 联合主键_Mysql 创建联合主键[通俗易懂]
.Net之延迟队列