![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
JAVA-基础
文章平均质量分 55
Rilan_
这个作者很懒,什么都没留下…
展开
-
求圆、长方形的面积
public class DisCountDemo { //求圆形面积 public double S(double r){ double syuan = Math.PI*r*r; return syuan; } //求长方形面积 public double S(int a,int b){ double schang = a*b; return sch原创 2017-10-25 09:18:46 · 919 阅读 · 0 评论 -
打印直角三角形,等腰三角形、直角梯形、等腰梯形
public class Dasanyuan { public static void main(String[] args){ /** * 打印直角三角形 */ final int row = 5;//要打印几行 for(int i=1;i<=row;i++){ //负责打印一个由星号组成的等腰直角三角形 for(int k=0;k<i;k++){原创 2017-10-25 09:38:44 · 4377 阅读 · 0 评论 -
冒泡排序
public class Dasanyuan { public static void main(String[] args){ //冒泡排序 int[] a= {25,54,69,8,7,456,36,47}; int temp; for(int i=0;i<a.length-1;i++) { for(int j=0;j<a.length-i-1;j++) { if(a原创 2017-10-25 09:44:28 · 205 阅读 · 0 评论 -
求个位、十位、百位上的数字
public class Dasanyuan { public static void main(String[] args){ //定义变量ge、shi、bai,用于存放个位、十位、百位上的数字 int ge ; int shi; int bai; int max=300; int min=200;原创 2017-10-25 09:49:58 · 11412 阅读 · 0 评论 -
求平方和
//定义整型变量n作为循环变量,并初始化 int n = 0; //定义整型变量sum存放和,并初始化 int sum = 0; //使用while循环求1到5的平方和 while(n<=5){ // sum = (int) (sum+Math.pow( n,2));原创 2017-10-25 09:52:25 · 1416 阅读 · 0 评论 -
求元音字母
//定义一个字符变量并初始化 Scanner a2 = new Scanner(System.in); System.out.println("请输入一个元音字母:"); char ch = a2.next().charAt(0);//从键盘接收字符型数据 //使用switch结构判断是否为元音字母,并输出对应的信息 switch(ch){ case '原创 2017-10-25 09:55:57 · 718 阅读 · 0 评论 -
使用三目运算符
int a = 10, b = 7; int max; max = a>b?a:b; System.out.println(max); boolean b1 = a>b?(3<6|3<1):(true == false); System.out.println(b1);运行结果:10true原创 2017-10-25 09:58:55 · 688 阅读 · 0 评论