//例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;}
1200字范文,内容丰富有趣,写作的好帮手!