我有一个队列循环(队列n
数),我想搜索所有大小的队列并找到最小大小的队列。
我只是想到了一个逻辑
std::queue<int> q;
/* fill queue ... */
int min_value = INT_MAX;
std::size_t size = q.size();
for( q=2; q=n; q++){ // from the second queue to the end queue
if
min_value=min.size() > q.size()?
q.size()=min_value
这个逻辑是否正确,我不确定,有人可以帮助我!
编辑:我试图弄清楚
std::queue<int> q;
/* fill queue ... */
int min_value = INT_MAX;
std::size_t size = q.size();
for( q=0; q<n; q++){ // given loop of queues
if
(q.size()<min_value) // q.size() is compared with the min_value (limits MAX)
min_value=q.size(); // any value of my q.size() which is less than INT_MAX will initially be declared the minimum value. On subsequent iterations this value is refined -- if a smaller value is found that's used for future iterations. at the end of loop, i will get the least value.
这个逻辑正确吗?