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: ...
随机推荐
- web大文件上传控件-设置附加参数-Xproer.HttpUploader6
自定义附加字段在up6.js中定义,也可以不用定义: 注意: 1.附加字段必须是字符串类型. 2.如果附加字段的值包含中文,在上传前必须使用encodeURIComponent进行编码. 在引 ...
- POJ-3481 Double Queue (splay)
The new founded Balkan Investment Group Bank (BIG-Bank) opened a new office in Bucharest, equipped w ...
- MongoDB整理笔记のGUI操作
值得幸运的是,其实MongoDB也有像类似于PL/SQL一样的界面操作工具操作MongoDB. 下面就来介绍几款不同的界面工具,大家各取所需! MongoVUE 主页:http://www.mongo ...
- Eclipse平台下配置Go语言开发环境(Win7)
<Go语言编程>中写到:“从功能和易用性等方面考虑, Eclipse+GoEclipse.LiteIDE这两个环境在所有IDE里面是表现最好的”,所以笔者打算采用Eclipse+GoEcl ...
- C#三层架构搭建
一.简介 主要分为:界面层(User Interface layer),业务逻辑层(Business Logic Layer),数据访问层(Data access layer) 1.作用 界面层(UI ...
- 解决低版本Xcode不支持高版本iOS真机调试的问题
1.现象截图 Could not locate device support files. This iPhone 6s is running iOS 11.1 (15B93), which may ...
- Unite Shanghai 2019全日程曝光(建议收藏)
https://mp.weixin.qq.com/s/KvAyXpDhqWROtTX1Ol3a4Q 5月10-12日,Unite Shanghai 2019即将在上海国际会议中心正式开幕.本次大会共设 ...
- ajax的get,post ,封装
let ajax = new Object(); ajax.get = function(url,fn){ //创建ajax对象 let xhr = new XMLHttpRequest(); //与 ...
- leecode刷题(6)-- 两个数组的交集II
leecode刷题(6)-- 两个数组的交集II 两个数组的交集II 描述: 给定两个数组,编写一个函数来计算它们的交集. 示例: 输入: nums1 = [1,2,2,1], nums2 = [2, ...
- 深度学习之 TensorFlow(五):mnist 的 Alexnet 实现
尝试用 Alexnet 来构建一个网络模型,并使用 mnist 数据查看训练结果. 我们将代码实现分为三个过程,加载数据.定义网络模型.训练数据和评估模型. 实现代码如下: #-*- coding:u ...