1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 9.C++例2-10 输入一系列整数 统计出正整数个数i和负整数个数j 读入0则结束。

9.C++例2-10 输入一系列整数 统计出正整数个数i和负整数个数j 读入0则结束。

时间:2023-11-28 01:40:43

相关推荐

9.C++例2-10 输入一系列整数 统计出正整数个数i和负整数个数j 读入0则结束。

//例2-10 输入一系列整数,统计出正整数个数i和负整数个数j,读入0则结束。#include <iostream>using namespace std;int main() {int i=0,j=0,n;cout<<"Enter some integers please (enter 0 to quit):"<<endl;cin>>n;while(n!=0) {if(n>0) i += 1;if(n<0) j += 1;cin >> n;}cout<<"Count of positive integers:"<<i<<endl;cout<<"Count of negetive integers:"<<j<<endl;return 0;}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。