第一期练习题 - 第二题

George and Accommodation from CodeForces
#include <iostream>

using namespace std;

int main(void)
{
	int n, count, now, max;
	int i;

	count = 0;

	cin >> n;
	if(n >= 1 && n <= 100)
	{
		for(i = 0; i < n; i++)
		{
			cin >> now >> max;
			if(now <= max && now >= 0 && max >= 0 && now <= 100 && max <= 100)
			{
				if(max - now >= 2)
				{
					count++;
				}
			}
			else
			{
				break;
			}
		}
	}

	cout << count;

	return 0;
}

猜你喜欢

转载自blog.csdn.net/W1451469745/article/details/84834699