我在千峰培训的日子第六天
今日总结
今天也没讲啥知识点,一天都在练习老师昨天讲的方法,然后他给讲了一下。
自我感悟
char 'b' ;
c += 'b' - 'B' ;
c = c + ( 'b' - 'B' ) ;
老师知识点
public static int maxOfNumber ( int num1, int num2) {
}
public static boolean isMyUpper ( char c) {
}
public static boolean isMyNumber ( char c) {
}
public static boolean isMyEnglish ( char c) {
}
public static char toMyLower ( char c) {
}
public static void reverse ( int number) {
}
public static double cube ( double number) {
}
public static boolean isLeap ( int year) {
}
public static void isPositiveNumber ( int num) {
}
【以下内容,周一上午讲课之后再行完成,晚自习讲解】
以下内容自行封装方法:
1. 求15的阶乘
2. 用户输入一个数,求对应数的阶乘(考虑数据延展性)
3. 完成30位以内的斐波那契数列
1 1 2 3 5 8 13 21 34 55 89 144 ...
4. 分解质因数
例如:
30 ==> 2 * 3 * 5
90 ==> 2 * 3 * 3 * 5
40 ==> 2 * 2 * 2 * 5
核心:
如果当前目标数据可以被某一个素数整除之后,需要再次确认当前素数是否可以继
续整除目标数据
素数作为循环变量
5.
*****
*****
*****
*****
*****
6.
*
**
***
****
*****
7.
*
***
*****
*******
*********
文档注释[重点]:
作用: 解释代码中,类,变量,方法的使用要求和细节,【说明书】
在Java方法文档注释要求
/**
* 当前方法操作的简要概述和功能概述,可以在描述过程中加入案例和注意事项。
*
* @param 参数名1 针对于当前参数的解释和需求分析,功能概述
* @param 参数名2 针对于当前参数的解释和需求分析,功能概述
* @return 返回值数据信息描述和特殊情况说明
* 其他内容
* @throws 异常抛出
* @Exception 异常声明
* @since 最低版本要求
* @author 作者
* @date 日期
*/
class Demo {
public static void main ( String [ ] args) {
double ret = factorial ( 15 ) ;
System . out. println ( ret) ;
}
public static double factorial ( int num) {
double s = 1 ;
for ( int i= 2 ; i <= num; i++ ) {
s *= i;
}
return s;
}
}
class Demo {
public static void main ( String [ ] args) {
public static void main ( String [ ] args) {
fibonacci ( 30 ) ;
}
public static void fibonacci ( int count) {
System . out. println ( 1 ) ;
System . out. println ( 1 ) ;
int previous = 1 ;
int next = 1 ;
for ( int i = 1 ; i <= count - 2 ; i++ ) {
int temp = next;
next += previous;
previous = temp;
System . out. println ( next) ;
}
}
}
class Demo {
public static void main ( String [ ] args) {
splitPrime ( 89 ) ;
}
public static void splitPrime ( int num) {
for ( int i = 2 ; i <= num; i++ ) {
if ( num % i == 0 ) {
System . out. println ( i) ;
num /= i;
i-- ;
}
}
}
class Demo {
public static void main ( String [ ] args) {
}
public static void show ( int a, int b) {
int i;
int j;
for ( i = 1 ; i <= a; i++ ) {
for ( j = 1 ; j <= b; j++ ) {
System . out. print ( '*' ) ;
}
System . out. println ( ) ;
}
}
}