develop #1

Merged
HoseinA05 merged 4 commits from develop into main 2026-07-30 13:09:23 +00:00
Showing only changes of commit f15ca18ad2 - Show all commits
+11 -4
View File
@@ -19,10 +19,17 @@ public class MainExercises
the output has to be a two-dimensional array of characters, so don't just print the triangle!
*/
public char[][] generateTriangle(int n) {
// todo
return null;
char[][] triangle = new char[n][];
for(int i = 0; i < n; i++) {
triangle[i] = new char[i+1];
for(int j = 0; j <= i; j++){
if(j == 0 || i == n - 1 || i == j)
triangle[i][j] = '*';
else
triangle[i][j] = ' ';
}
}
return triangle;
}