السلام عليكم ......
بعد محاولات عديده وتكررارت لعمل برنامج يقوم حذف القيم الزوجية في القوائم الاحادية الديناميكية
رغم ان البرنامج لايظهر لي اي خطأ لكنه لايؤدي العمل المطلوب !!!!!!
#include <iostream>
using namespace std;
//struct
struct list
{
int data ;
list *next ;
};
void del_Ev(list *&head, list *&tail)
{
list *l_tail, *node ;
int found = 0 ;
node = tail ;
while(tail != NULL && !found)
{
if(tail->data % 2 == 0)
found = 1 ;
else
{
l_tail = tail ;
tail = tail->next ;
}
}
if(found)
{
if(node == tail)
{
head = head->next ;
delete node;
}
else
{
l_tail->next = tail->next ;
node = tail ;
tail = tail->next ;
delete node ;
}
}
}
int main()
{
list *node ,*tail ,
*head = NULL ;
int a[] = {1, 4, 6, 3, 7, 11, 8, 9, 10} ;
for(int i = 8 ; i <= 0 ; i--)
{
node = new list ;
node->data = a ;
node->next = head ;
head = node ;
}
while(head != NULL)
{
tail = head->next ;
head = head->next ;
}
del_Ev(head,tail) ;
return 0 ;
}الرجاء ايضاح لي غلطتي وسأكون شاكر لكم

