java例子

public class mp {
 public static void main (String args[])  //1
 {
  int temp;
  int a[]={2,5,45,215,0,8,7,5,8,10};
  for(int i=0;i<a.length-1;i++)
  {
   for(int j=i+1;j<a.length;j++)
    if(a[i]>a[j])
    {
     temp=a[i];
     a[i]=a[j];
     a[j]=temp;     
    }
  }
  for(int k=0;k<a.length;k++)
   System.out.printf("  %d",a[k]); 
  }
}

lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll

public class maopao {
 public static void main (String args[])  //1
 {
  int temp;
  int a[]={2,5,8,3,0,8,7,5,8,10};
  for(int i=1;i<a.length;i++)
  {
   for(int j=0;j<a.length-1-i;j++)
    if(a[j]>a[j+1])
    {
     temp=a[j];
     a[j]=a[j+1];
     a[j+1]=temp;     
    }
  }
  for(int k=0;k<a.length;k++)
   System.out.printf("  %d",a[k]);  
 }
}
llllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll

class circle
{
 static double PI=3.1415926;
 int rediums;
 public double areas()        //circle 类
 {
  return PI*rediums*rediums;  
 } 
 public void enlarge(int k)
    {
         rediums=rediums+k;
    }
}
class rectangle     //rectangle 类
{
 int width,length;
 public double areas()
 {
  return width*length;
 }
}
public class shape {
 public static void main(String args[])
 {
   
 circle c=new circle();
 //circle c1=new circle();
 rectangle r1=new rectangle();
 rectangle r2=new rectangle();
 c.rediums=10;
 
 r1.width=15;
 r1.length=20;
 r2.width=14;
 r2.length=21;
 double s1=c.areas();
 c.enlarge(10);
 double s2=r1.areas();
 double s3=r2.areas();
 double s4=c.areas();
 System.out.println("s1 has areas : "+s1); //第一个S大写;println;括号内无逗号
 System.out.println("s2 has areas : "+s2);
 System.out.println("s3 has areas : "+s3);
 System.out.println("s4 has areas : "+s4);
 }
}

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值