キューのループ (キューの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.
このロジックは正しいですか?