0.DOS命令
输入 功能 E: 切换到E盘 dir 查看当前路径内容 cd 目录 进入单级目录 cd …(两个点 csdn有问题) 回退到上级目录 cd 目录\目录 进入多级目录 cd \ 回退到盘符目录 cls 清屏 exit 退出
1.Scanner输入
Scanner sc = new Scanner ( System . in) ;
int n = sc. nextInt ( ) ;
short t = sc. nextShort ( ) ;
long l = sc. nextLong ( ) ;
float f = sc. nextFloat ( ) ;
double d = sc. nextDouble ( ) ;
chat c = sc. next ( ) . charAt ( 0 ) ;
String s = sc. next ( ) ;
String i = sc. nextLine ( ) ;
2.数据范围
类型 字节数 范围 byte 1 -27 ~ 27 -1 short 2 -215 ~ 215 -1 int 4 -231 ~ 231 -1 long 8 -263 ~ 263 -1 float 4 double 8 boolean 1 true / false char 2
3.输出语句
System . out. print ( ) ;
System . out. println ( ) ;
System . out. printf ( ) ;
4.字符串比较
String a, b;
a. equals ( b) ;
5.Math函数
Math . abs ( ) ;
Math . sqrt ( ) ;
Math . round ( ) ;
Math . ceil ( ) ;
Math . floor ( ) ;
Math . log ( ) ;
Math . sin ( ) ;
6.Arrays类
<0>头文件
import java. util. Arrays ;
<1>数组转换成字符串
1. String s = Arrays . toString ( ) ;
<2>比较数组
2. boolean f = Arrays . equals ( a, b) ;
<3>数组排序
3. Arrays. sort ( a) ;
<4>数组填充
4. Arrays. fill ( a, val) ;
Arrays . fill ( a, l, r, val) ;
<5>二分查找
5. int indx = Arrays . binarySearch ( a, aim) ;
int indx = Arrays . binarySearch ( a, l, r, aim) ;
<6>数组拷贝
6. int [ ] b = Arrays . copyOf ( a, a. length) ;
int [ ] b = Arrays . copyOf ( a, l, r) ;
7.类型转换
String s = sc. next ( ) ;
int n = Integer . parseInt ( s) ;
double d = Double . parseDouble ( s) ;
些许总结
while ( op-- > 0 )
while ( op-- )
while ( ( n = sc. nextInt ( ) ) > 0 )
while ( cin>> n)
if ( ( i& 1 ) == 1 ) System . out. print ( "奇数" ) ;
if ( i& 1 ) cout<< "奇数" ;