while循环案例
class While05{
public static void main(String[ ]args){
//练习1:使用while循环完成输出1------10中的每个数
/*int i =1;
while(i<=10){
System.out.println(i);
i++;
}*/
}
}
class While06{
public static void main(String[ ]args){
//练习2:使用while循环完成输出所有的两位数
int i =10;
while(i<=99){
if(i %2 !=0){
System.out.println(i);
}
i++;
}
//练习3:使用while循环完成输出50---100范围内所有的奇数
//练习3:
//第一种方法:
/*int i = 51;
while(i<=100){
System.out.println(i);
i +=2;
}*/
//第二种方法:
/*int i = 51;
while(i <=100){
if(i %2 !=0){
System.out.println(i);
}
i++;
}*/
}
}
class While07{
public static void main(String[ ]args){
//练习4:使用while循环完成输出所有三位数中能被4整除的数,并且每行显示5个
int i = 100,count = 0;
while(i <=999){
if(i % 4 == 0){
System.out.print(i + "\t");
count ++;
}
i++;
if(count % 5 ==0){
System.out.println();
}
}
}
}
while循环案例的更多相关文章
- for循环案例
for循环案例 今天给大家介绍点for循环的案例 1.大马驮2石粮食,中马驮1石粮食,两头小马驮一石粮食,要用100匹马,驮100石粮食,该如何调配? <!DOCTYPE html> &l ...
- c语言运算符优先级与while循环案例
sizeof可以获取数据类型的内存中的大小(字节) #include <stdio.h> #include <stdlib.h> // standared 标准 // inpu ...
- js中的for循环案例
打印99乘法表 for(var x=1; x<=9; x++) { for(var y=1; y<=x; y++) { document.write(y+"*&q ...
- python while循环案例
1.while循环语句基本结构? while condition: loop body 2.利用while语句写出猜大小的游戏: 设定一个理想数字比如:66,让用户输入数字,如果比66大,则显示猜测的 ...
- c语言循环案例
do while #include <stdio.h> #include <stdlib.h> int main() { int a = 1,b = 10; do { b -= ...
- For循环案例练习一基础版
输出1-10之间的数据 1 public class LX1 { 2 public static void main(String[] args) { 3 for (int x=1;x<=10; ...
- For循环案例---九九乘法表
概述:先创建一个Print99类,类中创建5个方法,分别为Test9901.Test9902.Test9903.Test9904.Test9905,分别打印出不同形状的九九乘法表,该类创建完成后再创建 ...
- Javascript-for循环案例-打印1-100之间所有的数字
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...
- 写多个物件css3循环动画案例原理
div { background-color: #67CF22; height: 100%; width: 6px; display: inline-block; -webkit-animation: ...
随机推荐
- Head First HTML与CSS、XHTML (中文版).(Elisabeth Freeman) PDF扫描版
面对那些晦涩的html书你不禁要问:“难道要成为专家之后才能读懂这些?”那么,你应该选择<head first html与css.xhtml(中文版)>真正来学习html.这本书对你来说, ...
- js定时执行函数
//方法一: //直接现定义函数 var time = window.setInterval(function(){ $('.lingdao_right').click(); },5000); //方 ...
- .net core .NET Core与.NET Framework、Mono之间的关系
.NET Core与.NET Framework.Mono之间的关系 首先想要知道.NET Core与.NET Framework.Mono之间的关系,就必须他们分别是什么,有什么用途? 一. .ne ...
- Promise超时情况
export const ERROR_PROMISE_TIMEOUT = 'ERROR_PROMISE_TIMEOUT'; export default function (promise, time ...
- php CI框架 使用PDO 的连接配置
$db['default'] = array( 'dsn' => 'mysql:dbname=hejun;host=192.168.137.127', //'hostname' => '' ...
- Java bean与Spring、Spring MVC关系
Java Bean Java语言欠缺属性.事件.多重继承功能.所以,如果要在Java程序中实现一些面向对象编程的常见需求,只能手写大量胶水代码.Java Bean正是编写这套胶水代码的惯用模式或约定. ...
- MySQL 学习笔记(二):数据库更新、视图和数据控制
基础准备: 在 school 数据库下建立student.course.sc 三个表: create table student( Sno ) primary key, Sname ) unique, ...
- centos6.5 git clone http 报错
自己搭建服务器环境为centos6.5,需要使用git clone 命令的时候报错 首先查看centos上安装的git版本,我的版本为1.7.10 报错后,查阅相关资料需将centos升级,操作如下 ...
- 通过html()的方法获取文本内容, form表单组件显示的值与获取到的值不一致的问题
我在通过 html()获取对应节点的内容,发现一个问题,获取到的 form表单组件的内容值是初始加载的值,而不是经过用户修改后的值.例如页面加载时组件<input type="text ...
- 命令行里打 cd 简直是浪费生命
简评:作为工程师,你在命令行下最常打的命令无非就是 cd 与 ls.这些年你浪费了多少时间? 作为一个程序员或者在 shell 中花费大量时间的人,你可能会经常以一种低效率的方式在目录中来回移动,特别 ...