解题思路:
注意事项:
参考代码:
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语言代码)浏览:539 |
【明明的随机数】 (C++代码)浏览:779 |
打水问题 (C语言代码)浏览:1066 |
兰顿蚂蚁 (C++代码)浏览:1044 |
C语言训练-大、小写问题 (C语言代码)浏览:724 |
C语言程序设计教程(第三版)课后习题8.4 (C语言代码)浏览:619 |
Hello, world! (C++代码)浏览:1744 |
C语言程序设计教程(第三版)课后习题9.6 (C语言代码)浏览:372 |
核桃的数量 (C语言代码)浏览:668 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:606 |