Third Course summary and test report writing Week (a)

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."

2. Write a Java program, find the value of + 13-23 + 33-43 + 973-983 + 993-1003 ... of.

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

4. The write Java programs, calculation 8 + 88 + 888 + 10 ... and the front.

5. If a number is exactly equal to the sum of its factors, this number is called the complete number. All finished programming the number of output within 1000.

6. write applications, output meets + ... + n <maximum positive integer 1 + 2 + 3 8888.

7. FIG below for printing cycle (isosceles triangle)

1.

Experiment Code
public class flowers {
    public static void main(String[] args) {
        int a,b,c;
        int sum=0,i;
        for (i=10;i<=99;i++)
        {
            a=i/10;
            b=(i%10)/1;
            c=i%1;
            sum=a*10+b*1+c;
            if (Math.pow(a,3)+Math.pow(b,3)+Math.pow(c,3)==sum)
            {
                System.out.println(i);
            }
        }
    }

}
Experimental results

2.

Experiment Code
public class zhi {
    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);
    }
}
Experimental results

3.

Experiment Code
public class three{
    public static void main(String[] args) {
        int a,b;
        long c=1,sum=0;
        for (a=1;a<=20;a++) {
            for (b=1;b<=a;b++) {
                c=c*b;
            }
            sum=sum+c;
            c=1;
        }
        System.out.println(sum);
    }
}
Experimental results

4.

Experiment Code
public class and {
    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);
    }
}
Experimental results

5.

Experiment Code
public class perfect {
    public static void main(String[] args) {
        int a,b,c;
        for (b=1;b<=1000;b++) {
            int sum=0;
            for (c=1;c<b;c++) {
                if (b%c==0){
                    sum=sum+c;
                }
            }if (sum==b){
                System.out.println(b);
            }
        }
    }
}
Experimental results

6.

Experiment Code
public class number {
    public static void main(String[] args) {
        int a,sum=0;
        for (a=1;sum+a<8888;a++) {
            sum=sum+a;
        }
        System.out.println(a-1);
        System.out.println(sum);
    }

}
Experimental results

7.

Experiment Code
public class copy {
    public static void main(String[] args) {
        int a,b,n=5;
        for (a=1;a<=n;a++) {
            for (b=1;b<=n-a;b++) {
                System.out.print(" ");
            }
            for (b=1;b<=a;b++) {
                if (a==b) {
                    System.out.print("*");
                }
                else {
                    System.out.print("* ");
                }
            }
            System.out.println("\n");
        }
    }
}
Experimental results

summarize

General structure of the program comprises three types: sequential structure, selection structure, cyclic structure. These three structures have only one entrance and only one exit. Learn the three different structures, as well as understand the use of these three structures.

Guess you like

Origin www.cnblogs.com/9557yxl/p/11520337.html