Question 1-5

Source: Internet
Author: User

1. Rabbit issue (Fibonacci series)

Public class Fibonacci {
Public static void main (string [] ARGs ){
System. Out. println ("the RABIT of 1th month: 1 ");
System. Out. println ("the RABIT of 2th month: 2 ");
Int F1 = 1, f2 = 1, F, M = 24;
For (INT I = 3; I <= m; I ++ ){
F = F2;
F2 = F1 + F2;
F1 = F;
System. Out. println ("the" + I + "th" + "month's RABIT is" + F2 );
}
}
}

2. Calculate the prime number between 100 and 201:

Public class primenum {
Public static void main (string [] ARGs ){
Int COUNT = 0;
For (INT I = 101; I <200; I + = 2 ){
Boolean B = false;
For (Int J = 2; j <= math. SQRT (I); j ++ ){
If (I % J = 0 ){
B = false;
Break;
} Else {
B = true;
}
}
If (B = true ){
Count ++;
System. Out. println ("the prime number is" + I );
}
}
System. Out. println ("the number of prime number is" + count );
}
}

 

3. Daffodils (narcissism ):

Public class narcissisticnum {
Public static void main (string [] ARGs ){
Int m, n, l;
For (int K = 101; k <1000; k ++ ){
M = K/100;
N = kb % 100/10;
L = K % 10;
If (M * m + n * n + L * l) = k ){
System. Out. println (K + "is so narcissitic !!! ");
}
}
}
}

4. decomposition prime factor:

Import java. util. collections;

Public class decompositionofthequalityfactor {
Public static void main (string [] ARGs ){
Required bytes = new bytes (system. In );
System. Out. println ("Please input a int number :");
Int n = response. nextint ();
Int K = 2;
System. Out. Print (n + "= ");
While (k <= N ){
If (k = N ){
System. Out. Print (N );
Break;
} Else if (N % K = 0 ){
System. Out. Print (K + "*");
N = N/K;
} Else {
K ++;
}

}
}
}

5. Score level judgment:

Import java. util. collections;

Public class scoregrade {
Public static void main (string [] ARGs ){
Int X;
Char grade;
Required bytes = new bytes (system. In );
System. Out. println ("Please input a score :");
X = response. nextint ();
Grade = x> = 90? 'A': x> = 60? 'B': 'C ';
System. Out. println ("the grade is:" + grade );
}
}

Question 1-5

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.