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: ...
随机推荐
- css总结19:HTML5 Canvas(画布)
1 <canvas> 标签定义图形,比如图表和其他图像. 例1:简单使用: <canvas id="Canva" width="200" h ...
- BZOJ 4034[HAOI2015]树上操作(树链剖分)
Description 有一棵点数为 N 的树,以点 1 为根,且树点有边权.然后有 M 个操作,分为三种:操作 1 :把某个节点 x 的点权增加 a .操作 2 :把某个节点 x 为根的子树中所有点 ...
- 转Delphi中XLSReadWrite控件的使用(3) 读和写Excel
unit OpExcell; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Fo ...
- HtmlAgilityPack 使用
或.无属性.属性个数.属性值: var preceding_siblings = node.SelectNodes("preceding-sibling::input| preceding- ...
- Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'blog.t_blog.addTime' which is not functi
sql报错: Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Expression #1 of SELECT ...
- React + Dva + Antd + Umi 概况
Dva 由阿里架构师 sorrycc 带领 team 完成的一套前端框架,在作者的 github 里是这么描述它的:"dva 是 react 和 redux 的最佳实践". Ant ...
- GitHub+Hexo 搭建个人网站详细教程
原文链接 GitHub+Hexo 搭建个人网站详细教程 前言: 随着互联网浪潮的翻腾,国内外涌现出越来越多优秀的社交网站让用户分享信息更加便捷.然后,如果你是一个不甘寂寞的程序猿(媛),是否也想要搭建 ...
- utp
接口测试大致分为两种:数据驱动和代码驱动 数据驱动:主要处理用例之间没有关联关系的用例集合,一般以(excel.yaml)文件形式存储用例 代码驱动:主要是处理用例之间存在关联关系的用例(如:抽奖,需 ...
- asp手动给combox赋值
ASPxComboBox cbSex = ASPxGridView1.FindEditFormTemplateControl("cmbUSER_SEX") as ASPxCombo ...
- 洛谷P4501/loj#2529 [ZJOI2018]胖(ST表+二分)
题面 传送门(loj) 传送门(洛谷) 题解 我们对于每一个与宫殿相连的点,分别计算它会作为多少个点的最短路的起点 若该点为\(u\),对于某个点\(p\)来说,如果\(d=|p-u|\),且在\([ ...