Untitled
unknown
plain_text
7 months ago
815 B
9
Indexable
int main()
{
int n = 5, a;
bool adev= 0;
cin >> a;
struct List {
string id;
int data;
List* next;
};
List List1, List2, List3, List4, List5, temp;
List1.id = "0";
List2.id = "1";
List3.id = "2";
List4.id = "3";
List5.id = "4";
List1.data = 120;
List2.data = 234;
List3.data = 32;
List4.data = 636;
List5.data = 91;
temp.next = &List1;
List1.next = &List2;
List2.next = &List3;
List3.next = &List4;
List4.next = &List5;
for (int i = 1;i <= n;i++)
{
//cout << temp.next->data<<" ";
if (a == temp.next->data)
adev = 1;
if (adev==true)
cout << temp.next->id << " ";
temp = *temp.next;
}
return 0;
}Editor is loading...
Leave a Comment