码迷,mamicode.com
首页 > 其他好文 > 详细

20151203练习

时间:2015-12-03 21:22:54      阅读:241      评论:0      收藏:0      [点我收藏+]

标签:

技术分享
package shiyan;

public class Yiyuanercifangcheng {

    public static void main(String[] args) {

        int a = 10, b = 20, c = 30;

        if (a == 0) {
            System.out.println("不是一元二次方程");
        } else {
            int d = b * b - 4 * a * c;
            if (d == 0) {
            } else if (d > 0) {
                System.out.println("两个不相等的实根");
            } else if (d == 0) {
                System.out.println("两个相同的实根");
            } else {
                System.out.println("没有实根");
            }
        }

    }

}
一元二次方程
技术分享
package shiyan;

public class Shengaotizhong {

    public static void main(String[] args) {
        int sg = 188, tz = 91;
        boolean n = false;

        int bztz = 3;

        if (n) {
            bztz = sg - 100;
        } else {
            bztz = sg - 110;
        }

        if (bztz - sg > 3) {
            System.out.println("偏重");
        } else if (bztz - sg < -3) {
            System.out.println("偏轻");
        } else {
            System.out.println("正常");
        }
    }

}
身高 体重

技术分享
//循环
        int i=10;
        while(i>0)//逻辑表达式    控制循环次数     计数器
        { 
            if(i==8)//跳过这个代码继续运算
            {
                i--;
                continue;
            }
            System.out.println(i--);
            
            if(i==5)//终止条件
            break;
        }
循环语句 while

技术分享
//循环
        int i=10;
        while(i>0)
        { 
            if(i==8)
            {
                i--;
                continue;
            }
            System.out.println(i--);
            
        }
        
       do
        {
            
            System.out.println(i++);
        }
           while(i<0);//先运行一次
        
循环语句 do while
技术分享
public class Test {

    public static void main(String[] args) {
        
        for (int m=0;m<10;m++)//定义m  执行条件     执行循环
        {
            if(m==8) continue;
            System.out.println("m="+m);
        }
    

}    
for循环

 


 

20151203练习

标签:

原文地址:http://www.cnblogs.com/cuikang/p/5017439.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!