나는 C#을 몰라하지만 난 자바에 도움이됩니다 5. 원하는대로 구문을 변경해야합니다 (Console.Write
== System.out.print
& & Console.Writeline
== System.out.println
).
static void printPattern(int column){
int spaceCount = 2;//number of spaces before **, change as needed
int k;//number of times ** is printed each row, must remain always 1
for(int i = 0; i < column; i++){
System.out.println();//starts each row with a new line
for(int j = 1; j < spaceCount; j++){
System.out.print(" ");//prints j spaces in each row
}
spaceCount++;//increment spacecount each row, so j can also go + 1
for(k = 1; k <= 1; k++){
System.out.print("**");//each row prints ** k times
}
k--;//k must remain 1
}
}
그림 (3) 그림에 대한 printPattern(4);
전화 (4) printPattern(5);
당신이 오류를받을 수 있나요 질문 – CR41G14
을 다시 실행하십시오 : 그래서 여기에 코드를 간다? 자세한 내용은 http://www.dotnetfunda.com/articles/article2028-getting-different-shapes-of-stars-using-for-loops.aspx – Zaki
메신저 꽤이 컴파일되지 않습니다. 그 뒤에 무엇입니까
? – Thousand