Created
January 4, 2016 16:13
-
-
Save Jack-Saleem/200b58c4b1f1016afe30 to your computer and use it in GitHub Desktop.
Codeforces 233A PerfectPermutation in java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class PerfectPermutation | |
{ | |
public static void main(String[] args) | |
{ | |
Scanner z=new Scanner(System.in); | |
int n=z.nextInt(); | |
int arr[]=new int[n]; | |
for(int i=0;i<n;i++) | |
arr[i]=i+1; | |
int temp; | |
if(n%2==0) { | |
for(int i=1;i<n;i+=2) { | |
temp=arr[i]; | |
arr[i]=arr[i-1]; | |
arr[i-1]=temp; | |
} | |
for(int a:arr) | |
System.out.print(a+" "); | |
} | |
else | |
System.out.println(-1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment