企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
**打印三角形** \* \*\* \*\*\* \*\*\*\* \*\*\*\*\* ``` public class day04lianxi{ public static void main(String [] args){ for (int i = 1;i <= 5;i++){ // 控制行数 for (int j = 1;j <= i;j++){ // 控制每行内容 System.out.print("*"); } System.out.println(); } } } ``` <br> **计算出1-100之间所有奇数和偶数之和** ``` public class day05lianxi2{ public static void main(String [] args){ int odd = 0; int even = 0; for(int i = 0;i <= 100;i++){ if(i % 2 == 0){ even += i; }else{ odd += i; } } System.out.println("odd is :" + odd); System.out.println("even is :" + even); } } ``` **打印金字塔** ``` * * * * * * * * * * * * * * * ``` ``` public class day06lianxi3{ public static void main(String [] args){ for (int i = 1;i <= 5;i++){ for (int j = 1;j <= 5 - i;j++){ System.out.print(" "); } for (int j = 1;j <= i;j++){ System.out.print("* "); } System.out.println(); } } } ```