☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺☺ • 1年前
using namespace std;
typedef struct node {
int value;
node *next;
} lnode, *linklist;
void chushihua(linklist &l) {
l = new node;
l->next = NULL;
}
void shuru(linklist &l) {
linklist r = l;
int x;
cin >> x;
while (x != -1) {
linklist p = new node;
p->value = x;
p->next = r->next;
r->next = p;
r = p;
cin >> x;
}
int n, m;
cin >> n >> m;
int i;
linklist y = l;
while (y->next != NULL) {
if (y->next->value > n && y->next->value < m) {
y->next=y->next->next;
//delete y;
} else {
y = y->next;
}
}
}
void wrnm(linklist &l) {
node *cur = l->next;
while (cur != NULL) {
cout << cur->value << " ";
cur = cur->next;
}
cout << endl;
}
int main() {
linklist l;
chushihua(l);
shuru(l);
wrnm(l);
return 0;
}
评论:
请先登录,才能进行评论