polinominal

hi blogger friends, I did not make the long post, months ago I was on vacation to refresh my mind.

Well, in this post I will create a sample program to find the number polinominal.
Indonesian language program for syntax, I think you’ll understand the syntax.

okay, this is a program, use the overload and recursively.

# include <iostream>
# include <conio.h>

class poly {
friend ostream & operator << (ostream &, poly &);
friend istream & operator >> (istream &, poly &);
public:
poly ();
void sum (const poly &, const poly &);
void value (int);
private:
element int [100];
int a lot;
};

poly :: poly () {
for (int i = 0; i <lot; i + +)
elements [i];
}
istream & operator >> (istream & in, poly & a) {
cout << “a lot of elements:”; in >> a.banyak;
cout << “enter the data polynomial: \ n”;
for (int i = 0; i <a.banyak; i + +) {
cout << “variable power” << i << “:”;
cin >> a.elemen [i];
}
return in;
}
void poly :: value (int i) {
a lot = i;
}
ostream & operator << (ostream & out, poly & a) {

for (int i = (a.banyak-1); i> = 0; i -) {
cout << a.elemen [i];
if (i! = 0) cout << “x ^” << i << “+”;
}
cout << endl;
return out;
}
void poly :: sum (const poly & a, const poly & b) {
if (a.banyak> b.banyak) lot = a.banyak;
else a lot = b.banyak;
for (int i = 0; i <lot; i + +) {
if ((a.banyak-1) <i) elements [i] = b.elemen [i];
else if ((b.banyak-1) <i) elements [i] = a.elemen [i];
else elements [i] = a.elemen [i] + b.elemen [i];
}
}

int main () {
poly x, y, z;
cin >> x;
cout << x;
cin >> y;
cout << y;
z.penjumlahan (x, y);
cout << “\ n \ nhasil sum of two polynomial \ n” << z << endl;
getch ();
return 0;

okay, as that program syntax example, if you do not understand the language please comment.🙂
thanks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: