sicily--1636. show me the money

自作聪明,在循环中加入了判断,结果是还没输入完就结束了循环,导致错误了

#include<iostream>
using namespace std;

int main()
{
	int caseNum = 0;//测试个数
	cin >> caseNum;
	while(caseNum--)
	{
		int totalMoney = 0;
		int cannons = 0;
		cin >> totalMoney >> cannons;
		for(int i = 0; i < cannons; i++)
		{
			int price = 0;
			int numbers = 0;
			cin >> price >> numbers;
			totalMoney = totalMoney - price * numbers;
			//if(totalMoney < 0)//剩余钱不够买炮
			//{
			//	break;//可以输出Not enough了
			//}
			
		}
		if(totalMoney < 0)
		{
			cout << "Not enough" << endl;
		}
		else
		{
			cout << totalMoney << endl;
		}
	}
	return 0;
}


你可能感兴趣的:(测试,Numbers)