久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

帶 for 循環(huán)的無符號(hào) int 反向迭代

Unsigned int reverse iteration with for loops(帶 for 循環(huán)的無符號(hào) int 反向迭代)
本文介紹了帶 for 循環(huán)的無符號(hào) int 反向迭代的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我希望 for 循環(huán)中的迭代器變量作為 unsigned int 反向迭代到 0,我想不出與 i > 類似的比較.-1,就像如果它是 signed int 一樣.

I want the iterator variable in a for loop to reverse iterate to 0 as an unsigned int, and I cannot think of a similar comparison to i > -1, as you would do if it was a signed int.

for (unsigned int i = 10; i <= 10; --i) { ... }

但這似乎很不清楚,因?yàn)樗蕾囉跓o符號(hào)整數(shù)的數(shù)值溢出超過 10.

But this seems very unclear, as it is relying on the numerical overflow of the unsigned integer to be above 10.

也許我只是沒有清醒的頭腦,但有什么更好的方法可以做到這一點(diǎn)...

Maybe I just don't have a clear head, but whats a better way to do this...

免責(zé)聲明:這只是一個(gè)簡(jiǎn)單的用例,10 的上限是微不足道的,它可以是任何東西,并且 i 必須是一個(gè) unsigned int.

Disclaimer: this is just a simple use case, the upper limit of 10 is trivial, it could be anything, and i must be an unsigned int.

推薦答案

可以使用

for( unsigned int j = n; j-- > 0; ) { /*...*/ }

它從 n-1 向下迭代到 0.

It iterates from n-1 down to 0.

這篇關(guān)于帶 for 循環(huán)的無符號(hào) int 反向迭代的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

What do compilers do with compile-time branching?(編譯器如何處理編譯時(shí)分支?)
Can I use if (pointer) instead of if (pointer != NULL)?(我可以使用 if (pointer) 而不是 if (pointer != NULL) 嗎?)
Checking for NULL pointer in C/C++(在 C/C++ 中檢查空指針)
Math-like chaining of the comparison operator - as in, quot;if ( (5lt;jlt;=1) )quot;(比較運(yùn)算符的數(shù)學(xué)式鏈接-如“if((5<j<=1)))
Difference between quot;if constexpr()quot; Vs quot;if()quot;(“if constexpr()之間的區(qū)別與“if())
C++, variable declaration in #39;if#39; expression(C++,if 表達(dá)式中的變量聲明)
主站蜘蛛池模板: 狠狠操av| 天天干天天舔 | 男女交配网站 | 亚洲国产精 | 日本亚洲天堂 | 亚洲天堂影院 | 欧美久久久 | 一级黄色录像带 | 国产在线视频91 | 国产综合在线视频 | 成年免费视频黄网站在线观看 | 毛片毛片毛片 | 日韩欧美在线观看视频 | xxxxx黄色| 国产亚洲欧洲 | 五月精品| 视频一区在线观看 | 中文字幕在线网站 | 亚洲美女一区 | 成人蜜桃视频 | 欧美成人免费在线视频 | 欧美三级韩国三级日本三斤在线观看 | 欧美激情综合 | 亚洲精品乱码久久久久 | 四虎成人影视 | 中文字幕免费在线看线人动作大片 | 午夜久久久久久久 | 中文字幕日韩在线观看 | 亚洲综合自拍 | 日本中文字幕一区 | 亚洲成人精品 | 伊人久久精品视频 | 一级片免费在线观看 | 天天爽天天操 | 日韩精品一区在线观看 | 国产免费黄色 | 成人欧美日韩 | 国产精品久久久一区二区三区 | 福利视频免费观看 | 久草福利在线 | 天天干天天操天天爽 |