5hahab
شنبه 02 خرداد 1394, 20:39 عصر
میخواستم بدونم سورسی که واسه این سوال نوشتم درست هستش یا نه . ممنون میشم اعلام کنید.
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#include <iostream>
#include <cstdlib>
using namespace std;
struct node{
int data;
node* next;
node* prev;};
class linkedlist{
private:
node* front;
public:
int Delete(node* n);
void show();
};
void linkedlist::show(){
cout<<"elements:";
node* cur=front;
while(cur != front){
cout<<cur->data<<',';
cur=cur->next;
}
}
int linkedlist::Delete(node* r){
if((front== NULL) || (r == NULL) || (r->next == NULL))
return -1;
else{
node* n;
n=r->prev;
if(r->next != NULL)
n=r->next->prev;
r->next=n->next;
}
}
int main()
{
return 0;
}
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#include <iostream>
#include <cstdlib>
using namespace std;
struct node{
int data;
node* next;
node* prev;};
class linkedlist{
private:
node* front;
public:
int Delete(node* n);
void show();
};
void linkedlist::show(){
cout<<"elements:";
node* cur=front;
while(cur != front){
cout<<cur->data<<',';
cur=cur->next;
}
}
int linkedlist::Delete(node* r){
if((front== NULL) || (r == NULL) || (r->next == NULL))
return -1;
else{
node* n;
n=r->prev;
if(r->next != NULL)
n=r->next->prev;
r->next=n->next;
}
}
int main()
{
return 0;
}