+ 1

I want to display my pattern as like this but it is not!!! Give some suggestion about this??

e d d c c b b a a b b c c d d e https://code.sololearn.com/cNcXiEn30444/?ref=app My some part is missing here so plzzzz check out my code n give suggestion about this!!!!! Dan Walker ‎ ‏‏‎Sreejith  Veerendra Kushwaha [A^dr3w] Dev Arun Tomar Donna Hans Larry Helga HAWKEYE

29th Sep 2018, 8:10 AM
Harsh Agrawal
Harsh Agrawal - avatar
4 Respuestas
+ 4
most of your programs are specific to one particular input, try to make generalized programs which works with user input and for the bottom part of your program, logic for the right side differs inversely, line no. 17 won't help with the right side. you can always make a second for loop, but your idea seems interesting.
29th Sep 2018, 5:29 PM
‎ ‏‏‎Anonymous Guy
+ 3
public class KitePattern { public static void main(String[] args) { // n-th letter starting from 'a'. // 5 => 'e', 26 => 'z' int n = 5; int size = n * 2 - 1; int mid = n - 1, p1 = mid, p2 = mid; // ctp : Character to print // Replace 97 with 65 to use uppercase // letters char ctp = (char)(97 + mid); for(int R = 0; R < size; R++) { for(int C = 0; C < size; C++) { if(C == p1 || C == p2) System.out.print(ctp); else System.out.print(" "); } if(R < mid) { --ctp; --p1; ++p2; } else { ++ctp; ++p1; --p2; } System.out.println(); } } }
29th Sep 2018, 7:11 PM
Ipang
0
‎ ‏‏‎Sreejith  So can u plzz give some siggestion about this?? Ipang can u plzz check out my code n tell me what part am i doing wrong n what can i do to make it correcr??
30th Sep 2018, 2:50 AM
Harsh Agrawal
Harsh Agrawal - avatar