PAT-1010 一元多项式求导

注意理解题意,关键词非零项,输入0 0特判。

#include 
#include 
#include 
#include 
using namespace std;

#define MAX 1000
int xishu[MAX],zhishu[MAX];
int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int m = 0, n = 0, i= 0;
    while (scanf("%d%d", &m, &n) != EOF)
    {
        if (n != 0)
        {
            xishu[i] = m, zhishu[i] = n;
            xishu[i] = xishu[i]*zhishu[i];
            if (zhishu[i] != 0)
                zhishu[i]--;
            i++;
        }
    }

    for (int j = 0; j < i; j++)
    {

        cout << xishu[j] << " ";
        cout << zhishu[j];
        if (j != i-1)
            cout << " ";
    }

    if (i == 0)
        cout << "0 0";

    return 0;
}


你可能感兴趣的:(PAT)