미로 알고리즘 코드를 작성 중이며 지금은 일부를 하드 코딩했다.하지만이를 확장 성을 위해 루프로 변경해야한다. 누군가 이것을 루프로 전환하는 방법을 알려 주실 수 있습니까?내 하드 코드에서 루프를 만들 필요가있다.
movement(x_3_vector.at(1),y_3_vector.at(1),x_4_vector.at(1),y_4_vector.at(1),"3");
movement(x_3_vector.at(2),y_3_vector.at(2),x_4_vector.at(2),y_4_vector.at(2),"3");
movement(x_3_vector.at(3),y_3_vector.at(3),x_4_vector.at(3),y_4_vector.at(3),"3");
movement(x_3_vector.at(4),y_3_vector.at(4),x_4_vector.at(4),y_4_vector.at(4),"4");
movement(x_3_vector.at(5),y_3_vector.at(5),x_4_vector.at(5),y_4_vector.at(5),"4");
movement(x_3_vector.at(6),y_3_vector.at(6),x_4_vector.at(6),y_4_vector.at(6),"4");
movement(x_3_vector.at(7),y_3_vector.at(7),x_4_vector.at(7),y_4_vector.at(7),"4");
movement(x_3_vector.at(8),y_3_vector.at(8),x_4_vector.at(8),y_4_vector.at(8),"4");
movement(x_3_vector.at(9),y_3_vector.at(9),x_4_vector.at(9),y_4_vector.at(9),"4");
movement(x_3_vector.at(10),y_3_vector.at(10),x_4_vector.at(10),y_4_vector.at(10),"5");
movement(x_3_vector.at(11),y_3_vector.at(11),x_4_vector.at(11),y_4_vector.at(11),"5");
movement(x_3_vector.at(12),y_3_vector.at(12),x_4_vector.at(12),y_4_vector.at(12),"5");
movement(x_3_vector.at(13),y_3_vector.at(13),x_4_vector.at(13),y_4_vector.at(13),"5");
movement(x_3_vector.at(14),y_3_vector.at(14),x_4_vector.at(14),y_4_vector.at(14),"5");
movement(x_3_vector.at(15),y_3_vector.at(15),x_4_vector.at(15),y_4_vector.at(15),"5");
movement(x_3_vector.at(16),y_3_vector.at(16),x_4_vector.at(16),y_4_vector.at(16),"6");
movement(x_3_vector.at(17),y_3_vector.at(17),x_4_vector.at(17),y_4_vector.at(17),"6");
movement(x_3_vector.at(18),y_3_vector.at(18),x_4_vector.at(18),y_4_vector.at(18),"6");
movement(x_3_vector.at(19),y_3_vector.at(19),x_4_vector.at(19),y_4_vector.at(19),"6");
movement(x_3_vector.at(20),y_3_vector.at(20),x_4_vector.at(20),y_4_vector.at(20),"6");
문제는 내가 그래서 가끔 가끔 문자열 "3"과 운동 기능을 3 번 호출해야하고, 내가 차지 내 미로에 얼마나 많은 세포에 따라 "운동"함수를 호출 할 필요가있다 문자열 "4"로 6 번 호출해야합니다 ... 등등 ...
고마워요! 루프와
어떻게 당신이 그것을 몇 번이나 전화를 알 수 있습니까? – janisz
"이 기능을 ... 가끔씩 호출해야합니다 ... 3 번 ... 가끔은 6 ... 가끔 5"라고하는 것은 무엇을 의미합니까? 무슨 기능? '운동? 또는 하드 코딩 된 값을 대체하고 자체가 '이동'을 호출하는 새로운 기능입니까? 또한, 그 지표는 무엇을 의미합니까? 항상 늘고 있습니까? 마지막에 문자열 값은 무엇입니까? 귀하의 질문에 중요한 것이 있습니까? 제기 된 내용과 정확히 일치하는 내용이 명확하지 않기 때문에 질문을 명확하게 편집해야합니다. – frasnian
방금 질문을 수정하여 이해하기가 쉽습니다. –