712. 正数

712. 正数

输入 6 个数字,它们要么是正数,要么是负数。

请你统计并输出正数的个数。

输入格式

六个数字,每个占一行。

输出格式

输出格式为 x positive numbers,其中 x 为正数的个数。

数据范围

输入数字的绝对值不超过 100。

输入样例:

7
-5
6
-3.4
4.6
12

输出样例:

4 positive numbers
#include <cstdio>

int main()
{
	int s = 0;
	
	for (int i = 1; i <= 6; i++)
	{
		double a = 0;
		scanf("%lf", &a);
		if (a > 0) s++;
	}
	
	printf("%d positive numbers\n", s);
	
	
	
	return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_42465670/article/details/115109708