2014年1月20日
摘要: //打印杨辉三角形。import java.util.Scanner;public class Yanghui_Triangle{ public static void main(String args[]){ //输入行数 Scanner scan= new Scanner(System.in); System.out.println("请输入杨辉三角形行数:"); int row = scan.nextInt(); int yanghui[][]= new int[row][]; System.out.println("杨辉三角形"); ... 阅读全文
posted @ 2014-01-20 17:29 sophine 阅读(364) 评论(0) 推荐(0) 编辑
摘要: 注:以下代码摘抄自《Java 编程手记-从实践中学习java》一书,摘抄目的用于学习和共享。1 冒泡排序//冒泡排序:遍历整个数组,在遍历中依次对相邻元素进行比较,如果两者次序不对,则交换它们的位置本例是从大到小排序),其结果是元素较大值犹如“水泡”一样浮到数组前面。然后再次遍历数组,重复上述过程直至把所有元素移到适合的位置。public class BubbleSort{ public static void main(String[] args){ int score[]={900,878,891,904,865,912,868,870,898,903}; //打印数组元素 S... 阅读全文
posted @ 2014-01-20 16:52 sophine 阅读(1493) 评论(0) 推荐(0) 编辑