有n个整数,使其前面各数顺序向后移m个位置,最后m个数变成最前面的m个数。
public class Example36 {
public static void main(String[] args) {
int[] m = { 18, 12, 23, 34, 95, 76, 57, 28, 9 };
moveElement(m, 5);
}
public static void moveElement(int[] m, int n) {
System.out.print("移位前的数组为:");
for (int r : m) {
System.out.print(r + " ");
}
if (n int[] b = new int[m.length];
for (int i = 0; i b[i + n] = m[i];
}
int j = 0;
for (int i = m.length - n; i b[j] = m[i];
j++;
}
System.out.print("\n移动" + n + "位后的数组为:");
for (int r : b) {
System.out.print(r + " ");
}
} else {
System.out.print("\n移动错误!");
}
}
}
本书将PHP开发与MySQL应用相结合,分别对PHP和MySQL做了深入浅出的分析,不仅介绍PHP和MySQL的一般概念,而且对PHP和MySQL的Web应用做了较全面的阐述,并包括几个经典且实用的例子。 本书是第4版,经过了全面的更新、重写和扩展,包括PHP5.3最新改进的特性(例如,更好的错误和异常处理),MySQL的存储过程和存储引擎,Ajax技术与Web2.0以及Web应用需要注意的安全
406
以上就是分享一个Java经典编程题的实例的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号