参考代码:
import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int m = scanner.nextInt(); int n = scanner.nextInt(); int a[] = new int[m + n]; int b[] = new int[n]; for (int i = 0; i < m; i++) { a[i] = scanner.nextInt(); } for (int i = 0; i < b.length; i++) { b[i] = scanner.nextInt(); } int m1 = scanner.nextInt(); int n1 = scanner.nextInt(); int j = 0;//通过j来记录n1元素的索引 for (int i = m1; i < m1 + n1; i++) { //循环需要被替换的元素 a[i] = b[j]; if (j == n1 - 1) { break; } j++; } if (m - m1 < n1) { m = m1 + n1; } System.out.print(a[0]); for (int i = 1; i < m; i++) { System.out.print("," + a[i]); } } }
0.0分
2 人评分
大小写转换 (C语言代码)浏览:859 |
C语言程序设计教程(第三版)课后习题8.8 (C语言代码)浏览:1430 |
【明明的随机数】 (C语言代码)浏览:787 |
IP判断 (C语言描述,蓝桥杯)浏览:1095 |
字符逆序 (C语言代码)浏览:615 |
关于C语言变量位置的问题浏览:273 |
printf基础练习 (C语言代码)浏览:1806 |
A+B for Input-Output Practice (I) (C语言代码)浏览:574 |
幸运数 (C++代码)浏览:2871 |
陶陶摘苹果2 (C++代码)浏览:549 |