Chapter 5 : Control Structures 2 : Repetition
import java.util.*;
import java.io.*; public class Loop { static Scanner console = new Scanner(System.in); public static void main(String[] args) { int i = 0;
int sum = 0; while ( console.hasNext() ) {
i = console.nextInt();
System.out.println(i);
sum = sum + i; } System.out.println("sum = " + sum); } }
这个代码,本来实验while和console.hasNext(),不知错在哪里
需要两次舒服EOF, why????
The break and continue statements are an effective way to avoid extra variables to control
a loop and produce an elegant code. However, these statements must be used very sparingly
within a loop. An excessive use of these statements in a loop will produce a spaghetti-code
(loops with many exit conditions) and could be very hard to understand and manage.
As stated earlier, all three loops have their place in Java and one loop can often replace
another. The execution of a continue statement, however, is where a while structure
differs from a for structure. In a while loop, when the continue statement is executed,
if the update statement appears after the continue statement, the update
statement is not executed. In a for loop, the update statement always executes.
Chapter 5 : Control Structures 2 : Repetition的更多相关文章
- Chapter 4 : Control Structures 1 : Selection
Although it need not be, the expression is usually an identifier. Whether it is an identifieror an e ...
- 【Scala】Scala之Control Structures
一.前言 前面学习了Scala的Numbers,接着学习Scala的Control Structures(控制结构). 二.Control Structures Scala中的控制结构与Java中的颇 ...
- Python - 4. Control Structures
From:http://interactivepython.org/courselib/static/pythonds/Introduction/ControlStructures.html Cont ...
- R Programming week2 Control Structures
Control Structures Control structures in R allow you to control the flow of execution of the program ...
- Scala Control Structures
Scala之Control Structures 一.前言 前面学习了Scala的Numbers,接着学习Scala的Control Structures(控制结构). 二.Control Struc ...
- AOAPC I: Beginning Algorithm Contests -- Training Guide (Rujia Liu) Chapter 3. Data Structures Fundamental Data Structures
10410 这题说的是给了一棵多叉树的 bfs遍历轨迹 和dfs 遍历 轨迹 在父节点向叶子节点扩展的时候优先遍历编号较小的节点.我还原出这课树特殊判定 根据bfs的顺序来建立这课树,用一个队列安排要 ...
- Scala入门指南与建议
最近在学习使用Scala语言做项目,感觉这门语言实在是太优美了!作为一个本科数学.研究生机器学习专业的混合人才(哈哈),这门语言真的是满足了普通计算机编程(告诉计算机怎么做)和函数式编程(告诉计算机做 ...
- Core Java Volume I — 3.8. Control Flow
3.8. Control FlowJava, like any programming language, supports both conditional statements and loops ...
- Methods and systems to control virtual machines
Methods and systems are provided to control the execution of a virtual machine (VM). A VM Monitor (V ...
随机推荐
- luogu P5320 [BJOI2019]勘破神机
传送门 首先我们要知道要求什么.显然每次放方块要放一大段不能从中间分开的部分.设\(m=2\)方案为\(f\),\(m=3\)方案为\(g\),\(m=2\)可以放一个竖的,或者两个横的,所以\(f_ ...
- HTTP协议 详解
前言 掌握HTTP协议是每一个开发者的基础,超详细的HTTP协议笔记 正文 HTTP协议格式总览 HTTP line HTTP Method(方法) 介绍了我们请求希望执行的操作类型. 方法有: GE ...
- 盒子取球C语言 蓝桥杯
盒子取球方法二今盒子里有 n 个小球,A.B 两人轮流从盒中取球,每个人都可以看到另一个人取了多少个, 也可以看到盒中还剩下多少个,并且两人都很聪明,不会做出错误的判断. 我们约定:每个人从盒子中取出 ...
- 【easy】479. Largest Palindrome Product
Find the largest palindrome made from the product of two n-digit numbers Since the result could be v ...
- 三, 练习 python索引 (list和tuple)
(1) 练习 请用索引取出下面list的指定元素: 1, # -*- coding: utf-8 -*- L = [ ['Apple', 'Google', 'Microsoft'], ['Java' ...
- TP5多模块开发
一般的thinkphp框架一般都是单模块开发的,但有时候我们可能需要进行多模块开发,例如添加个后台管理的模块.这次给人讲课,在Tp多模块开发的配置上翻车,感觉很有必要总结下,话不多说,直接上干货. 总 ...
- LoadRunner学习笔记(三)
一. LR如何监控Windows系统资源 一般通过LR进行压力测试,都需要实时监控服务端的系统资源,我们可以直接在远程连接服务器上面开启任务管理器 或者在控制面板中找到性能计数器来监控,但是为了在L ...
- c博客作业--分支、顺序结构
1.本章学习总结 1.1思维导图 1.2本章学习体会及代码量学习体会 1.2.1学习体会 对于本章学习我感觉对代码有了初步的了解,一些简单的题目可以熟练掌握,但现在解决一道题目花的时间过多,不易发现那 ...
- docker部署jira破解版
1.制作Dockerfile FROM cptactionhank/atlassian-jira-software:7.12.0 USER root # 将代理破解包加入容器 COPY "a ...
- Linux下创建共享文件夹
1,查看ip 地址 ifconifg: 2,查看是否安装samba服务器,rpm -qa | grep samba: 3,如果有该服务器,启动 service smb start,否则进行安装 yum ...