Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static String printTree(char t, char b, int s){
- String out = "";
- int test = s - s + 1;
- for(int i = 0; i <= s/2; i++){
- for(int k = 0; k < (Math.ceil(s/2)+1)-(i+1); k++){
- out += " ";
- }
- for(int j = 0; j < test; j++){
- out += t;
- }
- test+=2;
- out += "\n";
- }
- for(int i = 0; i < (test*0.25)-2; i++){
- out+= " ";
- }
- //this is where my error of having it off by 1 for certain numbers. In my previous one, you saw my over-thinking process.
- if((test/2)%2 == 0){
- for(int i = 0; i <= test/2; i++){
- out+= b;
- }
- }else{
- for(int i = 0; i <= test/2+1; i++){
- out+= b;
- }
- }
- return out;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement