PAT-B 1010. 一元多项式求导

测试点2,4 考察导函数为0的情况,此时应输出0 0 (真坑)


代码:

#include <iostream>

using namespace std;

int main()
{
	int n, m;
	bool first = true;

	while (cin >> n >> m)
	{
		if (m != 0) // or n*m != 0
		{
			if (first)
			{
				cout << n*m << " " << m-1;
				first = false;
			} else 
			{
				cout << " " << n*m << " " << m-1;
			}
		}
	}
	if (first == true)
	{
		cout << "0 0";
	}

	return 0;
}


你可能感兴趣的:(C++,多项式求导,PAT-B)