解题思路:
注意事项:
参考代码:
import java.util.Scanner;
public class Main {
static
Scanner sc = new Scanner(System.in);
public static void C(int M,int[] array){
for(int i=0;i<M;i++){
int A = sc.nextInt();
int B = sc.nextInt();
int temp = array[A-1];
array[A-1] = array[B-1];
array[B-1] = temp;
}
for(int i=0;i<array.length;i++){
System.out.println(array[i]);
}
}
public static void main(String[] arg){
int N = sc.nextInt();
int M = sc.nextInt();
int[] array = new int[N];
for(int i=0;i<N;i++){
array[i] = sc.nextInt();
}
C(M, array);
}
}
0.0分
1 人评分
分糖果 (C++代码)浏览:1493 |
最小公倍数 (C语言代码)浏览:878 |
C语言程序设计教程(第三版)课后习题5.5 (C语言代码)浏览:700 |
兰顿蚂蚁 (C++代码)浏览:1121 |
WU-复数求和 (C++代码)浏览:2065 |
三角形 (C++代码)递归(存在大量重复计算,容易出现时间超限)浏览:815 |
C语言程序设计教程(第三版)课后习题10.4 (C语言代码)浏览:569 |
1908题解浏览:666 |
C语言程序设计教程(第三版)课后习题5.5 (C语言代码)浏览:581 |
矩阵加法 (C语言代码)浏览:1746 |