import java.util.Scanner; public class 交换Easy { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int m=sc.nextInt(); int[] arr=new int[n]; for (int i = 0; i < arr.length; i++) { arr[i]=sc.nextInt(); } for (int i = 0; i < m; i++) { int a=sc.nextInt(); int b=sc.nextInt(); int number=0; if (a!=b) { number=arr[a-1]; arr[a-1]=arr[b-1]; arr[b-1]=number; } } for (int i = 0; i < arr.length; i++) { System.out.println(arr[i]); } } }
解题思路:
注意事项:
参考代码:
0.0分
0 人评分
C语言程序设计教程(第三版)课后习题7.2 (C语言代码)浏览:610 |
C语言考试练习题_排列 (C语言代码)浏览:1317 |
A+B for Input-Output Practice (VII) (C++代码)浏览:611 |
拆分位数 (C语言代码)浏览:1327 |
2^k进制数 (C语言描述,蓝桥杯)浏览:1420 |
C语言程序设计教程(第三版)课后习题5.6 (C语言代码)浏览:583 |
小O的数字 (C语言代码)浏览:1410 |
A+B for Input-Output Practice (III) (C语言代码)浏览:422 |
母牛的故事 (C语言代码)浏览:478 |
C二级辅导-公约公倍 (C语言代码)浏览:1310 |