Untitled
unknown
plain_text
a year ago
1.5 kB
7
Indexable
#include <iostream>
using namespace std;
struct Node {
float x, y, z;
Node* next;
};
typedef Node* node;
node makeNode(float a, float b, float c) {
node tmp = new Node();
tmp->x = a;
tmp->y = b;
tmp->z = c;
tmp->next = NULL;
return tmp;
}
node a = NULL;
node b = NULL;
void run() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
float x1, y1, z1;
cin >> x1 >> y1 >> z1;
node tmp = makeNode(x1, y1, z1);
if (a == NULL) {
a = tmp;
}
else {
node p = a;
while (p->next != NULL) {
p = p->next;
}
p->next = tmp;
}
}
int m;
cin >> m;
for (int i = 0; i < m; i++) {
float x2, y2, z2;
cin >> x2 >> y2 >> z2;
node tmp1 = makeNode(x2, y2, z2);
if (b == NULL) {
b = tmp1;
}
else {
node p1 = b;
while (p1->next != NULL) {
p1 = p1->next;
}
p1->next = tmp1;
}
}
for (int i = 0; i < m; i++)
{
int count = 0;
node tmp = a;
for (int j = 0; j < n; j++)
{
if (b->x == tmp->x && b->y == tmp->y && b->z == tmp->z)
{
cout << j << endl;
count++;
break;
}
tmp = tmp->next;
}
if (count == 0) cout << "KHONG" << endl;
b = b->next;
}
}
int main() {
run();
}
Editor is loading...
Leave a Comment