解题思路:
注意事项:
参考代码:
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二级辅导-同因查找 (C语言代码)浏览:660 |
简单的a+b (C语言代码)浏览:547 |
【亲和数】 (C语言代码)浏览:536 |
2003年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:653 |
C语言程序设计教程(第三版)课后习题5.8 (C语言代码)浏览:672 |
C语言程序设计教程(第三版)课后习题5.5 (C语言代码)浏览:552 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:537 |
C语言程序设计教程(第三版)课后习题5.5 (C语言代码)浏览:553 |
矩形面积交 (C语言代码)浏览:1293 |
理财计划 (C语言代码)浏览:465 |