解決輸入一組數據計算負值個數,沒有反映的問題

輸入一組數值之後,可以輸入Ctrl+X,然後enter便出現結果

# include <iostream> //輸入一組數據之後,要輸入Ctrl+X,然後鍵入enter便出現結果
int main() 
{ 
	int amount = 0, value; 
	while (std::cin >> value)
		if (value < 0) ++amount; 
std::cout << "Amountof all negative values read is " << amount << std::endl; 
system ("pause");
return 0;
} 


<img src="https://img-blog.csdn.net/20140816143752137?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvemhhbmd4aW40ODMy/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="" />
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章