با سلام
یه سوال ساختمان داده داشتم که سوالش اینه
برنامه ای بنویسید برای حذف یک گره از لیست پس از یک گره نامعلوم
برنامه پایین رو واسش نوشتم فقط نمیدونم درست نوشتم یا نه ممنون میشم بگید درست نوشتم یا نه
/* 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;};
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* n){
if((front== NULL) || (n == NULL) || (n->next == NULL))
return -1;
node* d;
if(front->next==NULL){
d=front;
front=NULL;
}
else{
node* r;
r = n->next;
n->next = r->next;
}
}
int main()
{
return 0;
}