标签:水仙花 pack 编写程序 技术 mat 图片 使用 main class
package new1;
import static java.lang.Math.pow;
public class Main {
public static void main(String[] args){
for(int i = 100;i<=999;i++){
int a = i/100;
int b = (i-a*100)/10;
int c = i%10;
if(i == pow(a,3)+pow(b,3)+pow(c,3)){
System.out.println(i);
}
}
}
}
2.实验结果
package new1;
import static java.lang.Math.pow;
public class Main {
public static void main(String[] args){
int sum1 = 0;
int sum2 = 0;
for(int i = 13;i<=993;){
sum1+=i;
i = i+20;
}
for(int j = 23;j<=1003;){
sum2+=j;
j = j+20;
}
int sum;
sum = sum1+sum2;
System.out.println(sum);
}
}
package new1;
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int m = sc.nextInt();
int sum = 0, num = 1;
for(int i = 1;i<=m;i++)
{
num = num*i;
sum = sum+num;
}
System.out.println(sum);
}
}
package new1;
public class Main {
public static void main(String[] args){
int sum = 0, n = 0;
int i;
for(i=1;;i++){
sum = sum+i;
if(sum>=8888){
break;
}
}
System.out.println(sum-i);
}
}
package new1;
public class Main {
public static void main(String[] args) {
int sum = 0, n = 0;
int i;
for(i=1;;i++){
sum = sum+i;
if(sum>=8888){
break;
}
}
System.out.println(sum-i);
}
}
package new1;
public class Main {
public static void main(String[] args) {
int i, j;
for(i = 1;i<=5;i++){ //循环五次
for(j = 5;j>=i;j--){ //输出空格
System.out.print(" ");
}
for(j = 1;j<=i;j++){
System.out.print(" *");
}
for(j = 5;j>=i;j--)
{
System.out.print(" ");
}
System.out.println();
}
}
标签:水仙花 pack 编写程序 技术 mat 图片 使用 main class
原文地址:https://www.cnblogs.com/yuanqizhizhi/p/11517780.html