The first experiment and learning summary report

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

Experiment code:

package shuixianhua;

public class shuixianhua {

public static void main(String[] args) {
    int x,y,z;
    for(int i=100;i<1000;i++) {
        x=i/100;
        y=i%10;
        z=(i%100)/10;
        if(Math.pow(x,3)+Math.pow(y,3)+Math.pow(z,3)==i) {
            System.out.println(i);
        }
        
    }
}

}
The results cap:

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

Experiment code:

package shuixianhua;

public class qiuzhi {

public static void main(String[] args) {
    int sum=0,y=1;
    for(int i=13;i<1004;i=i+10) {
        sum=sum+i*y;
        y=-y;
    }
    System.out.println(sum);
}

}

Screenshot results:

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

Experiment code:

package shuixianhua;

public class jiechenghe {

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

}

Screenshot results:

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

Experiment code:

package shuixianhua;

public class he {

public static void main(String[] args) {
    long sum=0,x=8,y=0;
    for(int i=0;i<10;i++) {
        y=y*10+x;
        sum=sum+y;
    }
    System.out.println(sum);
}

}

Screenshot results:

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.

Experiment code:

package shuixianhua;

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

}

Screenshot results:

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

Experiment code:

package shuixianhua;

public class max {

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

}

Screenshot results:

7. FIG below for printing cycle (isosceles triangle)

Experiment code:

package shuixianhua;

public class sanjiaoxing {

public static void main(String[] args) {
    int i,j,y;
    for(i=1;i<=5;i++)
    {
        for(j=5-i;j>=0;j--)
        {
            System.out.print(" ");
        }
        for(y=1;y<=i;y++) {
            System.out.print("* ");
        }
        System.out.println();
    }
  }

}

The results Screenshot:
Summary: The job and last semester c language hooks so big topic is not difficult, but the class is not very content with not very understanding, based on their own only to see more online video deepen understand, such as this week to learn this keyword, static keyword to see the video to learn online.

Guess you like

Origin www.cnblogs.com/fengmixinluo/p/11512166.html