标签:程序 它的 static 应用程序 lse 运行结果截图 i++ stat private
1.实验代码
public class ShuiXianHua {
public static void main(String[] args) {
for (int i = 100; i <1000 ; i++) {
int firstNum = i/100;
int secondNum = i/10%10;
int thirdNum = i%10;
if(firstNumfirstNumfirstNum + secondNumsecondNumsecondNum+thirdNumthirdNumthirdNum == i){
System.out.println("水仙花数为:" + i);
}
}
}
}
2.运行结果截图
1.实验代码
public class ForDemo{
public static void main(String[] args){
int sum = 0;
int i;
int n;
for( i = 13; i<=1003;){
for(n=1;n<=100;n++){
if(n%2==0)
sum-=i;
else
sum+=i;
i+=10;
}
}
System.out.println(sum);
}
}
2.运行结果截图
1.实验代码
public class ForDemo{
public static void main(String[] args){
long sum = 0;
for(int i=0;i<20;i++)
sum += factorial(i+1);
System.out.println(sum);
}
private static long factorial(int n){
int mult = 1;
for(int i=1;i<n+1;i++)
mult *= i;
return mult;
}
}
2.运行结果截图
1.实验代码
public class ForDemo{
public static void main(String args[]){
long a,b=0, c=0;
System.out.println("sum");
for(a=1;a<=10;a++){
b=b*10+8;
c+=b;
}
System.out.print(c);
}
}
2.运行结果截图
1.实验代码
public class ForDemo{
public static void main(String[] args){
int i,j;
int num = 0;
for(i=1; i<=1000; i++){
num = 0;
for(j=1; j<i; j++){
if(i%j == 0){
num = num+j;
}
}
if(i == num){
System.out.print(i+" ");
}
}
}
}
2.运行结果截图
1.实验代码
public class ForDemo{
public static void main(String[] args){
int sum=0;
int i;
for(i=1;sum+i<8888;i++){
sum=sum+i;
}
System.out.println("sum"+sum);
System.out.println(i-1);
}
}
2.运行结果截图
1.实验代码
public class ForDemo{
public static void main(String[]args){
for(int i=1; i<=5; i++){
for(int n=0; n<5-i; n++){
System.out.print(" ");
}
for(int x=1; x<=i; x++){
System.out.print("* ");
}
System.out.println();
}
}
}
2.运行结果截图
标签:程序 它的 static 应用程序 lse 运行结果截图 i++ stat private
原文地址:https://www.cnblogs.com/wsxjydbb/p/11508772.html