#include#include typedef struct node { int data; struct node* next; }*PNODE, NODE; PNODE header; //PNODE ender; PNODE create() { PNODE header = (PNODE)malloc(sizeof(node)); header->next = NULL; PNODE q = header; int n; scanf_s("%d", &n); while (n--) { int a; scanf_s("%d", &a); PNODE p = (PNODE)malloc(sizeof(node)); p->data = a; // p->next = header->next; p->next = NULL; q->next = p; q = p; } return header; } void delete1(PNODE header) { while (header->next) { if (header->next->data % 2 == 0) header->next = header->next->next; else header = header->next; } } void show(PNODE header) { header = header->next; while (header) { if (header->next == NULL) { printf("%d ", header->data); break; } else { printf("%d ", header->data); header = header->next; } } } int main() { PNODE p = create(); delete1(p); show(p); printf("n"); return 0; }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)