PAT - 1010. 一元多项式求导 (25)


#include <iostream> #include <vector> using namespace std; int main() { vector<int> p; int x; while (cin>>x) { p.push_back(x); } int p_size=p.size(); if(p_size!=0) // 0 denote no element in p, and will print "0 0" like p_size==2. { for(int i=0;i<p_size;i=i+2) { p[i]=p[i]*p[i+1]; p[i+1]=p[i+1]-1; if (p[i]!=0) { if(i!=0)cout<<' '; cout<<p[i]<<' '<<p[i+1]; } else { if(p_size==2) cout<<"0 0"; } } } else { cout<<"0 0"; } system("pause"); return 0; }

 

posted @ 2014-04-20 15:53  jonathan321  阅读(1261)  评论(0)    收藏  举报