当前位置: 代码迷 >> 综合 >> 打印字样“LOVE“
  详细解决方案

打印字样“LOVE“

热度:14   发布时间:2023-11-30 15:20:12.0

利用循环打印英文字样”LOVE"

package First;
/* 打印英文字样"LOVE"*			* * * * *   *         *   * * * * *
*			*       *    *       *    *
*			*       *     *     *     * * * * *
*			*       *      *   *      *      
*			*       *		* *       *     
* * * * *   * * * * *        *        * * * * *  */
public class LoveDesign {static char star = '*';static char space = '\0';public static void main(String[] args) {loveDesign();}public static void loveDesign() {for(int i=1; i<=5; i++) {switch(i) {case 1:print100();		break;case 2:print100();		break;case 3:print100();		break;case 4:print100();		break;case 5:print111();		break;}//print SpaceprintSpace();//print Oswitch(i) {case 1:print111();		break;case 2:print101();		break;case 3:print101();		break;case 4:print101();		break;case 5:print111();		break;}//print Space printSpace();//print VprintV(i);//print SpaceprintSpace();//print Eswitch(i) {case 1:print111();		break;case 2:print100();		break;case 3:print111();		break;case 4:print100();		break;case 5:print111();		break;}System.out.println(); }}//打印Vpublic static void printV(int i) { // 1 -5//空格 0 - 4for(int j=1; j<=i-1; j++) {System.out.print(space);}//星 1 - 1 for(int j=1; j<=1; j++) {System.out.print(star);}//空格 7-0for(int j=1; j<=9-2*i; j++) {System.out.print(space);}//星 0 1 - 1for(int j=i; j<=i; j++) {if(j!=5)System.out.print(star);}//空格 0 - 4for(int j=1; j<=i-1; j++) {System.out.print(space);}}//五行三列空格public static void printSpace() {for(int i=1; i<=3; i++) {System.out.print(space);}}// *  .public static void print100() {for(int i=1; i<= 9; i++) { if(i==1)System.out.print(star);else {System.out.print(space);}}}// * * * * *.public static void print111() {for(int i=1; i<= 9; i++) { if(i%2==1)System.out.print(star);else {System.out.print(space);}}}// *       *.public static void print101() {for(int i=1; i<= 9; i++) { if(i==1||i==9)System.out.print(star);else {System.out.print(space);}}}}

 

  相关解决方案