晚上敲的几段练习

晚上,看完的day04,

准备敲几行联系下手感。。

之前总是懒,不想动手。

现在发现动手太慢。。。


继续。。。。

class Demo{
	public static void main (String [] args){

	}
	
}	



class text{

	/*对给定数组进行排序。
		{5,1,6,4,2,8,9}
		*/
		public static void stort(int[] a ){
		for(int x=0;x<a.length-1;x++){
			for(int y=x+1;y<a.length-1;y++){
				if(a[x]>a[y]){
					int tem=a[y];
					a[y]=a[x];
					a[x]=tem;
					}
				}
			}
		for(int x=0;x<a.length;x++){
			System.out.print(a[x]+",");
			}
		}

	
	   
	   
	//2012-11-13-20:57
		/*

		----*
		---* *
		--* * *
		-* * * * 
		* * * * * 	
		
		*/
		public static void printxing(){
		for(int x=0;x<5;x++){
			for(int y=0;y<4-x;y++){
			System.out.print(" ");
			}
			for(int z=0;z<x+1;z++){
			System.out.print("* ");
			}
			System.out.println();
			
			
		}
	}	

	
	//联系3:练习:3000米长的绳子,每天减一半。问多少天这个绳子会小于5米?不考虑小数。
	//2012-11-13-20:4
	//	hafe3000();	
	//结果:3000米绳子在第10天后绳子少于5米
	public static void hafe3000(){
	int day=0;
	boolean pos =true;
	int lengh=3000;
	while (pos){
		lengh=lengh/2;
		++day;
		if(lengh<5)
		pos=false;	
 	}
	System.out.println("3000米绳子在第"+day+"天后绳子少于5米");
	}

	//练习2,获取从X到Y的和,没判断X和Y大小
	//getsum(1,100);
	//20:23
	public static void getsum(int x,int y){
		int sum=0;
		for(;x<=y;x++){
			sum+=x;
		}
		System.out.println("SUM="+sum);
	}

	
	//练习1打印99乘法表
	//2012-11-13-20:03
	//print99(50);
	public static void print99(int num){
			for(int x=1;x<=num;x++){
				for(int y=1;y<=x;y++){
					System.out.print(y+"*"+x+"="+x*y+"\t");
					}
					System.out.println();
				}
			}
		
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值