1

刘宸志 CEUA  •  1年前


include <bits/stdc++.h>

using namespace std;

struct node {

int data;
node *next;

}; node head, p, *r; int x;

//void f() { // p = head->next; // while (p->next != = NULL) { // if (p->data % 2 == 0) { // p = p->next; // } // p->next = NULL; // } //}

int main() {

cin >> x;
head = new node;
r = head;
while (x != -1) {
	p = new node;
	p->data = x;
	p->next = NULL;
	r->next = p;
	r = p;
	cin >> x;
}
p = head->next;
int k = 0;
while (p->next != NULL) {
	if (p->data % 2 != 0) {
		cout << p->data << ' ';
		k++;
	}
	p = p->next;

}

// while (p->next != NULL) { // // p = p->next; // }

if (k == 0) {
	cout << "No";
	return 0;
}
cout << p->data << endl ;

return 0;

}


评论:

请先登录,才能进行评论