见Acwing 712
#include <iostream> using namespace std; int main() { float num = 0; int count = 0; while (scanf("%f", &num) == 1) { if(num > 0) count++; } printf("%d positive numbers", count); }