小程序
2016-03-11 23:04
253 查看
源程序:
public class Test{
public static void main(String[] args){
final int NUM = 8 ;
int[] score = null ;
score = new int[NUM] ;
for(int i = 0 ; i < score.length ; i++){
score[i] = (int)(Math.random() * 1000) ;
}
int temp = 0 ;
for(int i = 0 ; i < score.length - 1 ; i++){
for(int j = i + 1 ; j < score.length ; j++){
if(score[i] > score[j]){
temp = score[i] ;
score[i] = score[j] ;
score[j]= temp ;
}
}
System.out.print("第" + (i+1) + "次排序结果为:") ;
for(int j = 0 ; j < score.length ; j++){
System.out.print(score[j] + "\t") ;
}
System.out.println() ;
}
System.out.print("最终排序结果为:") ;
for(int i = 0 ; i < score.length ; i++){
System.out.print(score[i] + "\t") ;
}
}
}
运行结果:
public class Test{
public static void main(String[] args){
final int NUM = 8 ;
int[] score = null ;
score = new int[NUM] ;
for(int i = 0 ; i < score.length ; i++){
score[i] = (int)(Math.random() * 1000) ;
}
int temp = 0 ;
for(int i = 0 ; i < score.length - 1 ; i++){
for(int j = i + 1 ; j < score.length ; j++){
if(score[i] > score[j]){
temp = score[i] ;
score[i] = score[j] ;
score[j]= temp ;
}
}
System.out.print("第" + (i+1) + "次排序结果为:") ;
for(int j = 0 ; j < score.length ; j++){
System.out.print(score[j] + "\t") ;
}
System.out.println() ;
}
System.out.print("最终排序结果为:") ;
for(int i = 0 ; i < score.length ; i++){
System.out.print(score[i] + "\t") ;
}
}
}
运行结果:
相关文章推荐
- 简单小程序
- Viewpage和Fragment实现页面切换,微信界面
- 第一次作业——四则运算小程序
- 对微信的评价
- 用JAVA进行图像识别的小程序
- 微信支付移动开发
- 自定义密码输入框PasswordInput 仿微信密码输入框
- Android微信支付爬坑
- 一个小程序:Instrumentation的使用
- 微信iOS 9适配总结
- 微信、微博、qq图标服务实现
- Android 基于google Zxing实现二维码、条形码扫描,仿微信二维码扫描效果
- 作为一名程序猿,我是如何看待微信应用号的
- 如何让页面只能在微信端打开?
- 微信WeixinJSBridge API
- 微信第三方登录Android注意事项
- iOS 微信分享 朋友圈
- 微信红包随机算法初探
- Android程序设计:快速录音小程序
- 微信公众平台如何添加管理员