Victor Bazarov写道:Victor Bazarov wrote: desktop写道:desktop wrote: >我如何找到下面定义的列表numsx中的最后一个元素? int * myfind(int * arr_start,int * arr_end,int& s){>How do I find the last element in the list numsx defined below?int* myfind(int* arr_start, int* arr_end, int& s) { 为什么''s'通过Why is ''s'' passed by > int not_found = 666; int * result =& not_found; while(arr_start!= arr_end){ if(*(arr_start)== s) { result = arr_start; } arr_start ++; } 返回结果;>int not_found = 666;int* result = &not_found;while (arr_start != arr_end){if (*(arr_start) == s){result = arr_start;}arr_start++;}return result; 杂乱,杂乱......鉴于界面(忘记666)你需要实现这一点 $ b / b > while(arr_start!= arr_end){ if(* arr_start == s) break; ++ arr_start ; } 返回arr_start;Clutter, clutter... Given the interface (forget the 666) youshould implement this as while (arr_start != arr_end) { if (*arr_start == s) break; ++arr_start; } return arr_start; >}>} 问题是我不能使用''break''。我将使用一个 自定义优化器,它不允许使用''break''关键字。Problem is that I am not allowed to use ''break''. I am going to use acustom made optimizer that will not allow the use of the ''break'' keyword. desktop写道:desktop wrote: Victor Bazarov写道:Victor Bazarov wrote: > desktop写道:>desktop wrote: >>如何找到下面定义的列表numsx中的最后一个元素? int * myfind(int * arr_start,int * arr_end,int& s){>>How do I find the last element in the list numsx defined below?int* myfind(int* arr_start, int* arr_end, int& s) { 为什么''s''通过 Why is ''s'' passed by >> int not_found = 666; int * result =& not_found; while(arr_start!= arr_end){ if(*(arr_start)== s) { result = arr_start ; } 返回结果;>>int not_found = 666;int* result = &not_found;while (arr_start != arr_end){if (*(arr_start) == s){result = arr_start;}arr_start++;}return result; 杂乱,杂乱......鉴于界面(忘了666)你应该实现这个( )(arr_start!= arr_end) { if(* arr_start == s) break; ++ arr_start; } 返回arr_start; Clutter, clutter... Given the interface (forget the 666) youshould implement this as while (arr_start != arr_end) { if (*arr_start == s) break; ++arr_start; } return arr_start; >>}>>} 问题是我不能使用''break''。我将使用一个 自定义优化器,它不允许使用''break'' 关键字。Problem is that I am not allowed to use ''break''. I am going to use acustom made optimizer that will not allow the use of the ''break''keyword. 哦,来吧!然后使用''return''。 V - 请删除资金''A'时通过电子邮件回复 我没有回复最热门的回复,请不要问Oh, come on! Use ''return'', then.V--Please remove capital ''A''s when replying by e-mailI do not respond to top-posted replies, please don''t ask 这篇关于找不到列表中的最后一个元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-17 16:13
查看更多