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

For 循環(huán)打印一個(gè)額外的逗號(hào)

For loop prints an extra comma(For 循環(huán)打印一個(gè)額外的逗號(hào))
本文介紹了For 循環(huán)打印一個(gè)額外的逗號(hào)的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

cout<<"Set B : {";
for(i=0;i<b;i++)
{
    cout<<setB[i];
    cout<<",";
}
cout<<" }"<<endl;

上面的代碼打印不正確.它應(yīng)該打印 Set B : {1,2,3} 但它打印一個(gè)額外的逗號(hào) ==> Set B : {1,2,3,}

The code above is not printing right. It should print Set B : {1,2,3} but it prints an extra comma ==> Set B : {1,2,3,}

任何幫助將不勝感激.提前致謝!

Any help would be appreciated. Thanks in advance!

推薦答案

使用

cout << "Set B : {";

for (i = 0; i < b; ++i) {
  if (i > 0) cout << ",";

  cout << setB[i];
}

cout << " }" << endl;

我改變了你的算法:

之前的意思是:先輸入數(shù)字再輸入逗號(hào)"

Before it meant : "Put the number and then put a comma"

現(xiàn)在的意思是:如果我身后有一個(gè)數(shù)字,就用逗號(hào),然后把數(shù)字"

Now it means : "If there is a number behind me put a comma, then put the number"

以前,您總是在打印數(shù)字時(shí)打印一個(gè)逗號(hào),因此您有一個(gè)額外的逗號(hào).

Before, you always printed a comma when you printed a number so you had an extra comma.

這篇關(guān)于For 循環(huán)打印一個(gè)額外的逗號(hào)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(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á)式中的變量聲明)
主站蜘蛛池模板: 欧美在线视频免费观看 | 欧美视频亚洲视频 | www.sihu| 亚洲福利在线观看 | 一二三区视频 | 国产成人精品视频 | 成人涩涩| 永久在线| av黄色在线| 欧美久久久久久 | 国产一级一片免费播放放a 免费国产视频 | 在线中文av| 亚洲自拍偷拍一区 | 成人看片网 | 国产视频黄色 | 日韩成人中文字幕 | 成人精品一区二区三区 | 久久久综合视频 | 日日干夜夜草 | 精品一区二区三区四区五区 | 夜夜嗨av一区二区三区网页 | 亚洲一级免费视频 | a在线免费观看 | 国产黄网 | 久久国产精品免费视频 | 成人精品影院 | av激情影院 | 一区二区影视 | 免费毛片视频 | 九九热在线精品视频 | 日韩在线视频观看 | 九九在线免费视频 | 欧美视频在线观看免费 | 精品欧美在线 | 欧美成人精品一区二区三区 | 一级黄片毛片 | 久久国产一区二区三区 | 国产美女在线播放 | 亚洲激情在线播放 | 操欧美女人 | 毛片av在线 |