Мне нужна ваша помощь с программой, которая обрабатывает текст в формате ASCII.
Программа должна написать букву или слово в стиле ASCII, заданном в качестве входных данных. >
Проблема в том, что программа мне все время возвращает в конце букву «А», написанную в стиле ASCII.
Не могли бы вы посмотреть и скажи мне, что ты думаешь?
Код:
import java.util.*;
class Solution {
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
// Read the length (L) of the ASCII style
int L = in.nextInt();
// Read the height (H) of the ASCII style
int H = in.nextInt();
in.nextLine(); // Pour consommer la ligne vide
// Read the word to be displayed in ASCII style
String T = in.nextLine();
// Read the ASCII Style
StringBuilder styleBuilder = new StringBuilder();
for (int i = 0; i < H; i++) {
String ROW = in.nextLine();
styleBuilder.append(ROW).append("\n");
}
String style = styleBuilder.toString();
// Display the word using the ASCII style provided
String[] lines = style.split("\n");
int lineCount = lines.length;
int wordLength = T.length();
int letterWidth = wordLength * L;// Each letter is assumed to occupy L characters
for (int i = 0; i < lineCount; i++) {
StringBuilder printedLine = new StringBuilder();
for (int j = 0; j < letterWidth; j++) {
int letterIndex = j / L; // Each letter occupies L characters
char c = (letterIndex < wordLength) ? T.charAt(letterIndex) : ' ';
int index = j % L; // Hint in ASCII style line
printedLine.append(lines.charAt(index));
}
System.out.println(printedLine);
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/784 ... t-probleme