Computers and Technology

Write a program ThueMorse. java that takes an integer command-line argument n and prints an n-by-n pattern like the ones below. Include two space characters between each + and - character.
Have to use array and cannot call string method charAt.
Hint provided was to use boolean array of length n.
This is my current code:
public class ThueMorse {
public static void main(String[] args) {
int n = Integer. parseInt(args[0]);
String[] tm = {"0", "1"};
tm[0] = "0";
tm[1] = "1";
for (int k = 1; k <= n; k++) {
String t = tm[0];
String m = tm[1];
tm[0] += m;
tm[1] += t;
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (tm[0].charAt(i) == tm[0].charAt(j))
System. out. print("+ ");
else
System. out. print("- ");
}
System. out. println();
}
}
}

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 11:00, kingethan08
Ihave an iphone 8plus should i get another phone like samsung note 9 or s9 ? ?
Answers: 2
image
Computers and Technology, 23.06.2019 06:30, eddsworldfrantic
You have a small company and want to keep your costs low, but it is important your employees share data. which network would provide you with the most economical solution?
Answers: 1
image
Computers and Technology, 23.06.2019 06:40, euniceyi56
How many nibbles can be stored in a 16-bit word?
Answers: 1
image
Computers and Technology, 23.06.2019 11:30, talyku7131
Me dangers of social media and the internetexplain what each means: 1) social media and phones have become an addiction.2) outside people have access to you all the time.3) cyberstalking4) cyberbullying5) catphishing6) viruses7) identity theft8) credit card fraud9) hacking10) money schemes
Answers: 1
Do you know the correct answer?
Write a program ThueMorse. java that takes an integer command-line argument n and prints an n-by-n...

Questions in other subjects:

Konu
English, 04.03.2021 20:00
Konu
English, 04.03.2021 20:00