Now it's your turn to code the Remove Mean Friends method in BlueJ. I'll show
you some working pseudocode, but feel free to try it yourself first, and then
come back to look at the pseudocode. We'll create a variable i, which starts at
the beginning of the friends list. Now, while i is a valid index of friends, we
either remove the i-th friend or increment i. We remove the ith friend if the
ith friend doesn't have this person as a friend. And otherwise we increment i.
Cay would like you to pay close attention to the answer to this question, even
if you get it right. This algorithm is going to be important again, later in
the course.
Ahora es su turno de codificar el método removeMeanFriends en BlueJ. Les mostraré
algunos pseudocódigos que funcionan, pero no dudes en intentarlo primero tú mismo y luego
regresa y utiliza el pseudocódigo. Crearemos un variable i, que comienza al
inicio de la lista de amigos. Ahora bien, aunque i es un índice de amigos válido, debemos
ya sea eliminar al amigo i-ésimo o incrementar i. Quitamos al amigo i-ésimo si el
amigo i-ésimo no tiene a esta persona como un amigo. De lo contrario, incrementamos i.
A Cay le gustaría que prestes mucha atención a la respuesta a esta pregunta, incluso
si tu respuesta es correcta. Este algoritmo va a ser importante de nuevo en lecciones posteriores en
el curso.
C'est à votre tour de coder la méthode
Remove Mean Friends dans BlueJ.
Je vous montrerai
un pseudocode fonctionnel,
mais essayez d'abord tout seul,
puis revenez pour voir le pseudocode.
Nous allons créer une variable i, qui
commence au début de la liste d'amis.
Alors que i est un index valide d'amis,
soit nous enlevons le i-ème ami,
soit nous l'incrémentons.
Nous enlevons l'ami si ce dernier
n'a pas cette personne comme ami.
Et sinon nous incrémenterons i.
Cay aimerait que vous soyez attentif
à la réponse de cette question,
même si vous réussissiez.
Cet algorithme sera à nouveau
important, plus tard dans le cours.
今度は皆さんがBlueJで
removeMeanFriendsメソッドをコーディングします
疑似コードをお見せしますが自分で試すまで
見なくても結構です 友人リストの
始めからスタートする変数iを作ります
iが有効な友人のインデックスである間は
i番目にいる友人を削除するか
iをインクリメントします
i番目にいる友人がこの人を友人としなければ
i番目の友人を削除します
そうでなければiをインクリメントします
正解しても
ケイはこの解答をよく見てほしいそうです
このアルゴリズムはコース後半で
再び重要になってきます
이제 Bluej에서 removeMeanFriends 메소드를 구현할 차례입니다. 여러분에게
슈도코드를 작성해드리겠습니다. 하지만 여러분이 먼저 프로그램을 스스로
구현 시켜도 됩니다. friends 목록에서 시작하는 i 변수를 먼저
선언합니다. i가 friends 안의 유효한 인덱스라면, i번째 친구를
삭제하거나, i를 증가시킵니다. i번째 친구가 이 person의
친구가 아니라면 삭제를 합니다. 그렇지 않다면 i를 증가시킵니다.
Cay 교수님은 이 질문의 답을 유심히 보라고 했습니다. 맞았다고 해도
자세히 봐야 합니다. 이 알고리즘은 이 강좌에서 또 사용할
겁니다.