+ 1
Help me doing this pattern as soon as possible
abcdedcba abcd dcba abc cba ab ba a a
2 ответов
+ 2
here is the code :
public static void printFormula(String s , int counter ){
if(s.length() == 0){
return;
}
for(int k = 0 ; k < s.length() ;k++){
System.out.print(s.toCharArray()[k]);
}
for(int i = 0; i < counter ; i++){
System.out.print(" ");
}
for(int k = s.length()-1; k > -1 ;--k){
System.out.print(s.toCharArray()[k]);
}
System.out.println("");
print(s.substring(0, s.length()-1), ++counter);
}
public static void main(String[] args) {
printFormula("abcde" , 0);
}
+ 2
System.out.print("abcdedcba\nabcd dcba\nabc cba\nab ba\na a");
If You need quicker method then use machine code:D