And experimental study summary report Monday

And experimental study summary report Monday

Third Course summary and test report writing Week (a)

1. printout of all the "number of Narcissus", 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. Write Java programs, find the value of + 13-23 + 33-43 + 973-983 + 993-1003 ... of.

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

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

  4. If it is exactly equal to a number of factors and, this number is called the complete number. All finished programming the number of output within 1000.

  5. Write applications, the output of the maximum positive integer satisfying 1 + 2 + 3 + ... + n <8888's.

  6. For the following cycle using FIG print (isosceles triangle)

1, daffodils.

package 作业;

public class 水仙花 {
    public static void main(String[] args) {
        int x,y,z;
        int sum=0,i;
        for (i=100;i<=999;i++)
        {
            x=i/100;
            y=(i%100)/10;
            z=i%10;
            sum=x*100+y*10+z;
            if (Math.pow(x,3)+Math.pow(y,3)+Math.pow(z,3)==sum)
            {
                System.out.println(i);
            }
        }
    }

}

2, the evaluator

package 作业;

public class 求值 {
    public static void main(String[] args) {
        int i,a=0,b=1,c=3;
        for (i=1;i<=100;i++)
        {
            a=a+b*(c+(i*10));
            b=-b;
        }
        System.out.println(a);
    }
}

3, factorial

package 作业;

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

4, find the sum of the first ten

package 作业;

public class 求和 {
    public static void main(String[] args) {
        long a=0,b=0,i;
        for (i=1;i<=10;i++)
        {
            a=a*10+8;
            b=b+a;
        }
        System.out.println(b);
    }
}

5, find the number of End

package 作业;

public class 完数 {
    public static void main(String[] args) {
        int a,i,j;
        for (i=1;i<=1000;i++) {
            int sum=0;
            for (j=1;j<i;j++) {
                if (i%j==0)
                {
                    sum=sum+j;
                }
            }
            if (sum==i)
            {
                System.out.println(i);
            }
        }
    }

}

6, the maximum positive integer

package 作业;

public class 最大整数 {
    public static void main(String[] args) {
        int i,a,sum=0;
        for (i=1;sum+i<8888;i++) {
            sum=sum+i;
        }
        System.out.println(i-1);
        System.out.println(sum);
    }

}

7. Print

package 作业;

public class 打印 {
    public static void main(String[] args) {
        int i,j,n=5;
        for (i=1;i<=n;i++) {
            for (j=1;j<=n-i;j++) {
                System.out.print(" ");
            }
            for (j=1;j<=i;j++) {
                if (i==j) {
                    System.out.print("*");
                }
                else {
                    System.out.print("* ");
                }
            }
            System.out.println("\n");
        }
    }

}

Learning content summary:

1, in the presence of four major Java memory space in
the stack memory space: save all object name (the address reference stored in the heap memory).
Heap memory to: save the contents of the specific attributes of each object
and global data: static storage type of property
global code District: save all the methods defined
2, static call restrictions:
the method can be declared a non-static method to call static properties declared.
The method is declared static properties can not call the non-static type declaration methods.
3, on the usefulness of this
can be emphasized using this method of the class.
It represents class attributes
may be used to call this method of the present class constructor
this represents the current object

When do the final topic, which is printed isosceles triangle there have been many problems, there are many questions are not taken into account,
such as a space between each print line to wrap, for this topic, I print out a handstand space triangle
reprint of a triangle with an asterisk, at the time of printing, I do not know how to solve the
spaces between, so the reference to the practice of students
the following code

for (j=1;j<=i;j++) {
                if (i==j) {
                    System.out.print("*");
                }
                else {
                    System.out.print("* ");
                }
            }

For space and output is output from right to left, one per line , all other *, on either wrap with
System.out.println ( "\ n");
you can also use System.out.println (); the second more general use.

Guess you like

Origin www.cnblogs.com/neir/p/11518806.html