0
Star and numbers pattern
Can anyone help me how to code in java a pattern like this one given n = 5 ? *234 **34 ***4 ****
10 Answers
+ 3
Roberto Where is your try??
+ 3
Roberto You can use a classic loop where at any iteration "i", you print:
- I+1 times "*"
- sequence of int starting from i+1 to n
+ 2
Roberto Post anyway because its a proof that you dont ask for easy solution (eg. other make your assignement for you)... Sorry, but here there are many requests like that type
+ 1
Thanks I'll try the i+1 times "*" suggestion and see...
+ 1
Roberto Please, when you post some code, its helpful to who help you, if you save it in Code Playground section and post his link in comment... For now i made it for you but next time, please, do yourself...Anyway, this is your code which i have added some comments hints
https://code.sololearn.com/cFep9ZIIG9p2/?ref=app
+ 1
I got it finally ...
https://code.sololearn.com/cb6TVsnR4zjQ/?ref=app
+ 1
Roberto Nice work đđđ
0
There is not... to difficult for me, I tried but the result is not the one expected
0
Sorry actually for the given example n should be equal to 4
0
I tried this code below, which of course is wrong, but I can't figure out how to print the desidered pattern:
public class Main {
public static void main(String[] args) {
int n = 5;
int i, j;
for (i = 1; i < n+1; i++) {
String row = "";
for (j = 1; j < n+1; j++) {
if (i == j) {
row += "* ";
System.out.print(row + "\n");
} else {
System.out.print(j);
}
}
}
}
}
*
23451*
34512*
45123*
51234*