PAT1010 一元多项式求导 (25 分)
生活随笔
收集整理的這篇文章主要介紹了
PAT1010 一元多项式求导 (25 分)
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
題目
代碼
//3 4 -5 2 6 1 -2 0 #include<iostream> #include<vector> using namespace std; class Multi { public:int xishu;int zhishu; };int main() {Multi temp;vector<Multi>arr;int xishu, zhishu;//輸入while (cin >> xishu >> zhishu){temp.xishu = xishu;temp.zhishu = zhishu;arr.push_back(temp);}//求導int i;int total = arr.size();for (i = 0; i < total; i++){arr[i].xishu *= arr[i].zhishu;arr[i].zhishu -= 1;}//刪除零項for (i = 0; i < total; i++){if (arr[i].xishu == 0){arr.erase(arr.begin() + i);i--;total--;}}//輸出total = arr.size();if (total == 0){cout << "0 0";return 0;}for (i = 0; i < total; i++){cout << arr[i].xishu << ' ' << arr[i].zhishu;if (i != total - 1)cout << ' ';}//system("pause");return 0; }總結(jié)
以上是生活随笔為你收集整理的PAT1010 一元多项式求导 (25 分)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: PAT1009 说反话 (20 分)【c
- 下一篇: PAT1011 A+B 和 C (15