用三种循环语句来实现输出10~50之间的3的倍数,并规定一行输出5个数。

匿名 (未验证) 提交于 2019-12-03 00:27:02

用三种循环语句来实现输出10~50之间的3的倍数,并规定一行输出5个数。

package Test;   /**  * @Author liguo  * @Description3. 用三种循环语句来实现输出10~50之间的3的倍数,并规定一行输出5个数。  * @Data 2018-03-29 18:44  */ public class Test3 {      public static void main(String[] args) {         int count = 0;         for (int i = 10; i <= 50; i++) {             if (i % 3 == 0) {                 count++;                 System.out.print( i + "  " );             }             if (count % 5 == 0)                 System.out.println();         }    //        int i = 10; //        int count = 0; //        do { //            if (i % 3 == 0) { //                System.out.print( i + "  " ); //                count++; //            } //            if (count % 5 == 0) //                System.out.println(); //            i++; //        } while (i <= 50 && i >= 10); //   //        int i = 10; //        int count = 0; //        while (i <= 50 && i >= 10) { //            if (i % 3 == 0) { //                System.out.print( i + "  " ); //                count++; //            } //            if (count % 5 == 0) //                System.out.println(); //            i++; //        } } } 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!