my project has stop working

Hi every one .... I am a new student at IT technology......
I cant find the problem here :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
#include<iostream>
#include<cmath>

using namespace std;

struct record
{
	float val;
	int power;
};

struct poly
{
	 record num;
	 poly *next;
};




void insert(poly *& , record );
void insertadd(poly *& , record );
void readpoly(poly *&);
void writepoly(poly *);
void addpoly(poly *& , poly *& , poly *&);
void multpoly(poly *& , poly *& , poly *&);

//=====================================================

void main()
{
	
	char choise;
	poly *ph=NULL,*ph1=NULL,*ph2=NULL,*ph3=NULL;


	do 
	{
		cout<<"enter your choise    :"<<endl;
		cout<<"----------------------"<<endl;
		cout<<"press r to read poly :"<<endl;
		cout<<"press w to write poly:"<<endl;
		cout<<"press a to addpoly   :"<<endl;
		cout<<"press m to multpoly  :"<<endl;
		cout<<"press e to end       :"<<endl;
		cout<<"----------------------"<<endl;
		cin>>choise;
		switch (choise)
		{
	     	case ('r'):
			case ('R'):
							 

				readpoly(ph);
								 break;
							 
	    	case ('w'): 
			case ('W'):      {
								 writepoly(ph);
								 cout<<endl;
								 cout<<"-------------------"<<endl;
								 break;
							 }
		    case ('a'):
			case ('A'):
			                 {
								 cout<<"read poly 1 : "<<endl;
								 readpoly(ph1);
								 cout<<"read poly 2 : "<<endl;
								 readpoly(ph2);
								 addpoly(ph1,ph2,ph3);
								 cout<<" ***** add ruselt ******** "<<endl<<endl;
								 writepoly(ph3);
								 cout<<"-----------------------"<<endl;
								 break;
							 }
	    	case ('m'):
			case ('M'):
			                 {
								 cout<<"read poly 1 : "<<endl;
								 readpoly(ph1);
								 cout<<"read poly 2 : "<<endl;
								 readpoly(ph2);
								 multpoly(ph1,ph2,ph3);
								 cout<<" ***** mult ruselt ******** "<<endl<<endl;
								 writepoly(ph3);
								 cout<<"-----------------------"<<endl;
								 break;
							 }
	    	default : 
			                 {
								 cout<<" try again "<<endl;
								 break;
							 }
		}
	}
     while (choise = 'e');
}

//================================================
void insert (poly *&ph,record num3)
{
	poly *temp=new poly,*s,*prv;
	bool located=false;

	temp->num.val=num3.val;
	temp->num.power=num3.power;
	temp->next=NULL;

	if (ph=NULL)
		ph=temp;
	else
	{
		s=ph;
		while ((! located) && (s!=NULL))
		{
			if (s->num.power>num3.power)
			{
				prv=s;
				s=s->next;
			}
			else
				located=true;
		}

		if (s->num.power = num3.power)
		{
			while (s->num.power = num3.power)
			{
				cout<<"error,plz enter new element : ";
				cout<<"enter val :"<<endl;
				cin>>num3.val;
				cout<<"enter power :"<<endl;
				cin>>num3.power;
				insert(ph,num3);
			}
		}
		else
		{
		  temp->next=s;
	      if (s=ph)
			ph=temp;
		  else
			prv->next=temp;
		}
	}
}

//===================================================

void insertadd(poly *&ph,record num)
{
	poly *temp,*s,*prv;
	bool located=false;

	temp= new poly;
	temp->num.power=num.power;
	temp->next=NULL;

	if (ph=NULL)
		ph=temp;
	else
	{
		s=ph;
		while ((! located) && (s!=NULL))
		{
			if (s->num.power>num.power)
			{
				prv=s;
				s=s->next;
			}
			else
				located=true;
		}

		if (s->num.power = num.power)
			s->num.val = s->num.val + num.val;
		else
		{
		  temp->next=s;
	      if (s=ph)
			ph=temp;
		  else
			prv->next=temp;
		}
	}

}

//==================================================

void readpoly(poly *&ph)
{
	int size ;
	record num ;

   cout<<"how many elements do you enter: ";
   cin>> size;
   for (int i=1; i<=size; i++) 
   {
       cout<<"enter value: "<<endl;
       cin>> num.val;
       cout<<"enter power:  "<<endl;
       cin>> num.power;
	   insert (ph,num);
   }

}
//==================================================
void writepoly(poly *ph)
{
	poly *s;
	s=ph;
        while(s != NULL)
		{
			if(s->num.power=0)
				if(s->num.val>0)
					cout<<"+"<<s->num.val;
				else
                    cout<<s->num.val;
			else
				if (s->num.power=1)
					if (s->num.val>0)
						cout<<"+"<<s->num.val<<"x";
					else 
						cout<<s->num.val<<"x";
				else
					if (s->num.val>0)
						cout<<"+"<<s->num.val<<"x^"<<s->num.power;
					else
						cout<<s->num.val<<"x^"<<s->num.power;

			s=s->next;
		}
}
   
//===================================================
void addpoly(poly *&ph1 , poly *&ph2 , poly *&ph3)
{
	poly *t1,*t2; record num1;
	ph3=NULL;
	t1=ph1;
	while (t1 != NULL)
	{
		num1.power=t1->num.power;
		num1.val=t1->num.val;
		insert (ph3,num1);
		t1=t1->next;
	}
	t2=ph2;
	while (t2 != NULL)
	{
		num1.power = t2->num.power;
		num1.val = t2->num.val;
		insertadd(ph3,num1);
		t2=t2->next;
	}	
}
//=================================================

void multpoly (poly *&ph1, poly *&ph2,poly *&ph3)
{
	poly *t1,*t2; 
	record num1,num2,num3;
	ph3=NULL;
	t1=ph1;
	while (t1 != NULL)
	{
		num1.power=t1->num.power;
		num1.val=t2->num.val;
		t2=ph2;
		while (t2 != NULL)
		{
			num2.power=t2->num.power;
			num2.val=t2->num.val;
			num3.val=num1.val * num2.val;
			num3.power=num1.power + num2.power;
			insertadd(ph3,num3);
			t2=t2->next;
		}
		t1=t1->next;
	}
}
//=================================================================================================================== 
main must return int.

= assignment operator
== comparison operator

Your memory is leaking (there isn't a single delete). ¿Are you sure that you need dynamic allocation?

Try to abstract a little more. There is std::list

You can return values from functions
Topic archived. No new replies allowed.