题目描述:
George and Alex want to live in the same room. The dormitory has n rooms in total. At the moment the i-th room has pi people living in it and the room can accommodate qi people in total (pi ≤ qi). Your task is to count how many rooms has free place for both George and Alex.
题解:
只要判断qi-pi的值是否大于等于2就行了
#include<iostream>
using namespace std;
int main()
{ //第二题
int n,k=0,pi,qi;
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> pi >> qi;
if (qi - pi >= 2)
{
}
k++;
}
cout << k;
return 0;
}