Scanner用法
来源:互联网 发布:php str contains 编辑:程序博客网 时间:2024/04/30 04:35
- Scanner is suitable to read input data for the most of problems, but it is very slow. You should use it to read small input data only.
import java.util.Scanner;
public class Main1 {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
int a,b;
while(cin.hasNextInt()){
a = cin.nextInt();
b = cin.nextInt();
System.out.println(a+b);
}
}
}
下面这种用法也是正确的:
package test1;
import java.util.Scanner;
class YouCanUseSuchClasses {}
public class Main2 {
class AndSuchClassesToo {}
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
int a, b;
while(cin.hasNextInt())
{
a = cin.nextInt();
b = cin.nextInt();
System.out.println(a + b);
}
}
}
- scanner 用法
- Scanner用法
- Scanner用法
- Scanner用法
- Scanner 类 useDelimiter("")用法
- Scanner类用法
- Scanner 类的用法
- Java Scanner的用法
- 关于Scanner一些用法
- Scanner的用法误区
- Scanner的用法
- Scanner典型用法
- Java Scanner的用法
- Scanner类的用法
- scanner用法详解
- Scanner 类 useDelimiter("")用法
- Scanner类的用法
- Scanner的用法
- JavaScript学习笔记(1)
- MySQL 一闪退出解决
- STL中容器的删除操作
- 模拟Form提交,得到结果页内容
- 在Ubuntu上为Android系统内置C可执行程序测试Linux内核驱动程序
- Scanner用法
- OCCI
- Unix下两种后台执行SQL脚本的方法
- sql where 1=1和 0=1 的作用
- android 动画效果 简介
- 【MACOS】macbook pro使用感受
- 存储过程IF
- 几大排序算法舞蹈
- MyEclipse svn插件安装方法