#include <iostream> using namespace std; int main(int argc, char *argv[]) { istream_iterator<int> it(cin); istream_iterator<int> end; int count = 0; while(it != end) { if(*it++ < 0) { ++count; } } cout << "总共输入了 " << count << " 个负数" << endl; }
[此贴子已经被作者于2018-4-10 20:02编辑过]