本文介绍了使用java while循环打印trangle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 亲爱的, 任何人都可以帮助我设计java trangle使用while循环如下 * * * * * * * * * * 这样我需要设计我尝试设计但它显示无限。 这是我的代码 class Ex4 { public static void main( String [] san) { int z = 1 ; while (z< 7){ for ( int j = 0 ; j< = z; j ++) { for ( int i = 0 ; i< = j; i ++) {系统。 out .println( *); z ++; } 系统。 out .print( \\\); } } } } 解决方案 我看不到你可以使用的地方7.此外,问题需要两个嵌套循环,但你使用三个。 问题很简单。这个练习的想法是:你应该能够很快解决这些小问题,从理解问题到完全调试功能代码。这是一个简单的建议:重命名所有变量,然后给出一些语义名称,用不带缩写的英语单词表示,如 length , horizontalIndex , lineCount ,行。并正确格式化代码,严格按照其逻辑结构显示嵌套。它将帮助您立即查看代码正在做什么。 其余部分太简单,无法进一步讨论。我完成了你的家庭练习。请记住,你的学校让你有机会学习一些东西;如果有人给你一个完整的解决方案,你就会失去这个机会。 -SA dear all,can anyone plz help me to design java trangle using while loop as below * * * * * * * * * *in this way i need to design i try to design it but it is showing infinite.this is my codeclass Ex4{ public static void main(String [] san) { int z=1; while(z<7){ for(int j=0;j<=z;j++) { for(int i=0;i<=j;i++) { System.out.println("*"); z++; } System.out.print("\n"); } } }} 解决方案 I cannot see where you could use 7. Besides, the problem requires two nested loops, but you use three.The problem is very simple. The idea of this exercise is: you should be able to solve such small problems very quickly, from understanding the problem to having fully debugged functional code. Here is one simple advice: rename all variables to give then some semantic names, expressed in English words without abbreviations, like length, horizontalIndex, lineCount, line. And format the code properly, show nesting strictly according its logical structure. It will help you to see what the code is doing, immediately.The rest of it is too simple to discuss any further. I leave completion for your home exercises. Remember that your school gives you a chance to learn something; and you would loose this chance if someone gives you a complete solution.—SA 这篇关于使用java while循环打印trangle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!