参考代码:
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语言程序设计教程(第三版)课后习题8.7 (C语言代码)浏览:506 |
点我有惊喜!你懂得!浏览:1424 |
点我有惊喜!你懂得!浏览:1462 |
最小公倍数 (C语言代码)浏览:896 |
C语言训练-数字母 (C语言代码)浏览:670 |
C语言程序设计教程(第三版)课后习题8.5 (C语言代码)浏览:956 |
IP判断 (C语言代码)浏览:820 |
1011题解浏览:819 |
简单的a+b (C语言代码)浏览:529 |
复数求和 (C语言代码)浏览:995 |