The first week of the third week of lab reports and Lessons Learned

A printout of all the "Number of daffodils", the so-called "number Narcissus" means a 3-digit number, which is equal to the digits of the cube and the number itself. For example, 153 is a "number daffodils."

1. Experimental Source:

package shuixianhua;
public class shuixianhuaa{
public static void main(String args[]) {
int x,y,z,i;
for(i=100;i<=999;i++) {
x=i%10;
y=i/10%10;
z=i/100;
if(i==xxx+yyy+zzz) {
System.out.println(i);
}
}
}
}

2. Results:

II. Write Java programs, find the value of + 13-23 + 33-43 + 973-983 + 993-1003 ... of.

1. Experimental Source:

package java1;
public class java11 {
public static void main(String args[]){
int i=13;
int step=0; /判断奇偶/
int sum=0;
while(true){
if(i>1003)
break;
if(step%2==0){
sum=sum+i;
}else{
sum=sum-i;
}
step++;
i=i+10;
}
System.out.println(sum);
}
}

2. Results:

III. Programming seek 1! +2! +3! + ... + 20! .

1. Experimental Source:

package java2;

public class java22 {
public static void main(String args[]){
int i,j,fact;
int sum=0;
for(i=1;i<=20;i++) {
fact=1;
for(j=1;j<=i;j++)
fact=j*fact;
sum=sum+fact;
}
System.out.println(sum);
}

}

2. Experimental results

IV. Write Java programs, the calculation 8 + 88 + 888 + 10 ... and before it.

1. Experimental Source:

package java3;

public class java33 {
public static void main(String args[]) {
int i;
int n=8;
int sum=8;
for(i=1;i<10;i++) {
n=(n*10)+8;
sum=n+sum;
i++;
}
System.out.println(sum);
}

}

2. Experimental results

V. If a number is exactly equal to the sum of its factors, this number is called the complete number. Programming output of the 1000 count them all

1. Experimental Source:

package java4;

public class java44{
public static void main(String args[]) {
int i,j,s;
for(i=2;i<1000;i++) {
s=0;
for(j=i-1;j>0;j--) {
if(i%j==0)
s=s+j;
}
if(s==i)
{
System.out.println(i);
}
}
}
}

2. Experimental results

VI. Write applications, the output satisfies 1 + 2 + 3 + ... + Maximum positive integer n <8888 in

1. Experimental Source:

package java5;

public class java55 {

public static void main(String[] args) {
    int i;
    int sum=0;
    for(i=1;i>0;i++) {
        sum=i+sum;
        if(sum>8888) {
        
            System.out.println(i-1);
            break;
            
    }

}

}

}

2. Experimental results

VII. Use a for loop to print the graphic below

1. Experimental Source:

2. Results:

Summary: This is a few questions gave me the feeling is not very difficult, mainly used for operational use eclipse familiar, let me think C and Java links are inextricably linked and must learn to C on the basis of Java

The third week study concluded:

This week the main school construction method, Sring class-related content, this understanding and the static keyword and main () method, are quite difficult to understand; in particular, a program analysis, to understand the type of property and its class, and tested the code did not know, I think first of all still have to start to write, understand it in practice. Other keyword, there are many uses, too puzzled.

Guess you like

Origin www.cnblogs.com/saury/p/11455614.html