Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- / Input Poly
- cout << "Input p1: " << endl;
- Polynomial P1;
- cin >> P1;
- // Output Poly
- cout << "p1(x) = " << P1 << 'n' << endl;
- //Insertion
- ostream& operator<<(ostream& os, Polynomial Poly){
- for (int i=0; i < Poly.polyNum; i++) {
- os << Poly.poly[i] << " x^" << i;
- if(i != Poly.polyNum - 1){
- os << " + ";
- }
- }
- return os;
- }
- //Extraction
- istream& operator>>(istream& is, Polynomial Poly){
- int numP = 0;
- int * tempP;
- is >> numP;
- tempP = new int [numP+1];
- for (int i=0; i < numP; i++) {
- is >> tempP[i];
- }
- Poly.polyNum = numP;
- Poly.poly = new int[Poly.polyNum +1];
- for (int i=0; i < Poly.polyNum; i++) {
- Poly.poly[i] = tempP[i];
- }
- return is;
- }
- istream& operator>>(istream& is, Polynomial Poly)
- istream& operator>>(istream& is, Polynomial& Poly)
- Polynomial P1;
- cin >> P1;
Add Comment
Please, Sign In to add comment