行数 *数
1 1 7 8
2 3 5 7
3 5 3 6
4 7 1 5
5 9
public class forfor01 {
/**
*
* @Desciption
* @author Abraham
* @email 1290807550@qq.com
* @version JDK1.8
* @date 2021年3月16日上午9:01:04
*/
public static void main(String[] args) {
for (int j = 1; j <= 5; ++j) {
for(int a=1;a<=5-j;++a){
System.out.print(" "); }
for (int i = 1; i <= 2*j-1; ++i) {
System.out.print("*"); }
System.out.println();}
for (int j = 1; j <= 4; ++j) {
for(int a=1;a<=j;++a){
System.out.print(" "); }
for (int i = 1; i <= (8-2*j)+1; ++i) {
System.out.print("*"); }
System.out.println();}
?
?
/*for (int j = 1; j <= 5; ++j) {
for (int i = 1; i <=5-j; ++i) {
System.out.print("*"); }
*/ System.out.println();}
?
}
?
?
//九九乘法表代码:
public class forfor02 {
/**
*
* @Desciption
* @author Abraham
* @email 1290807550@qq.com
* @version JDK1.8
* @date 2021年3月16日上午9:01:04
*/
public static void main(String[] args) {
for(int i=1;i<=9;++i){
for(int j=1;j<=i;++j){
System.out.print(j+"*"+i+"="+(j*i)+"\t"); }
System.out.println();
}
}
}
?
public class forfor03 {
/**
*
* @Desciption
* @author Abraham
* @email 1290807550@qq.com
* @version JDK1.8
* @date 2021年3月16日上午9:01:04
*/
public static void main(String[] args) {
boolean isflag=true;
for (int i = 2;i <= 100; i++) {
?
for (int j = 2; j <Math.sqrt(i); j++) {
if (i % j == 0) {
isflag=false;
break;
}
}
if(isflag==true){
System.out.println(i);
}
isflag=true;
}
}}
?
原文:https://www.cnblogs.com/gabraham/p/14548718.html