首页 >>  正文

for循环输出星号三角形

来源:baiyundou.net   日期:2024-09-22

公胁学2909请人教下C#怎么用for输出星号三角形? -
崔独饲15024093517 ______ for (i=1;i{ for (j=1;j { Console.Write("*"); } Console.WriteLine(); }

公胁学2909C语言:输出下列图案,使用循环逐行输出: * *** ***** ******* ********* -
崔独饲15024093517 ______ main() {int i,j; for(i=0;i<5;++i) //打印5行,循环 { for(j=0;j<i*2+1;j++) //每行增加的星号数量的算法,i*2+1 { printf("*"); //循环打印j个星号 } printf("\n"); //每行结束回车换行 }

公胁学2909用C语言怎么循环输出三角形啊??? -
崔独饲15024093517 ______ for (j=1;j<=2*i-1;j++) 其中: i 行数 j 每行的*个数 例:第i=1行,循环2*i-1=1次 第i=2行,循环2*i-1=3次 ......

公胁学2909怎么用for循环打印三角形
崔独饲15024093517 ______ set serveroutput on declare k int; begin k:=&amp;k; for i in 1..k loop for j in 1..(1+2*(k-1)) loop if j=1 then dbms_output.put('|'); end if; if j&lt;k+i and j&gt;k-i then dbms_output.put('*'); else dbms_output.put(' '); end if; end loop; dbms_output.put_line(' '); ...

公胁学2909C语言中用循环程序输出一个十行的等边三角形(用*表示)怎么做 -
崔独饲15024093517 ______ #include <stdio.h> int main() { int i, j, k; for (i = 0; i <= 10; i++) { j = i * 2 + 1; k = 10 - i; while (k-- > 0) { printf(" "); } while (j-- > 0) { if (j % 2 != 0) printf("*"); else printf(" "); } printf("\n"); } return 0; }//*******************#include <stdio.h> int main() { ...

公胁学2909用java中简单的for循环输出以下星号,一定要java * * * * * * * * * * -
崔独饲15024093517 ______ 双层for for(){ for(){ 输出空格 } for(){ 输出星号 } } 根据行数计算空格的数量和星的数量

公胁学2909在JavaSprict中用for循环输出三角形? -
崔独饲15024093517 ______ 这个适合用双重for循环来做:function printstars(n) { for (var i = 0; i for (var j = 0; j document.write("*"); } document.write(""); } } printstars(5);

公胁学2909用java中的(for循环)打印如下三角形图形: ***** **** *** ** * -
崔独饲15024093517 ______ public class Shape4 { public static void main(String[] args) { // TODO Auto-generated method stub for(int i = 5; i > 0; i--){ for(int j = 0; j <= 4; j++){ if(j < i ){ System.out.print("*"); }else{ System.out.print(" "); } } System.out.println(); } } } 自己仔细...

公胁学2909java问题 用for循环输出三角形 -
崔独饲15024093517 ______ 把这句for(int j=1;j<=i;j++){改成for(int j=1;j<=i*2+1;j++){就可以符合你的要求了.

公胁学2909java如何简单的用for循环实现以下三角形; ***** **** *** ** * -
崔独饲15024093517 ______ 修改啊-_-||| 一个横竖两行的输出,你用了4个for...... 一般遇到这种情况,首先考虑只用两个for.算法上的优化比代码长度重要多了.public class test { public static void main(string[] args) { int limit = 8; for (int rowindex = 1; rowindex for (int colindex = 1, colindexmax = 2 * limit - 1; colindex system.out.print(rowindex (colindex ); } system.out.println(); } } }

(编辑:自媒体)
关于我们 | 客户服务 | 服务条款 | 联系我们 | 免责声明 | 网站地图 @ 白云都 2024