#include <bits/stdc++.h>
using namespace std;
struct Node {
int reg;
float cg;
Node* next;
};
Node* InsertAtBegin(Node* root, int reg,float cg) {
Node* newnode = new Node();
newnode->reg=reg;
newnode->cg=cg;
newnode->next = root;
if(root==NULL)
{
root=newnode;
return root;
}
else
{
newnode->next=root;
root=newnode;
return root;
}
}
void Print(Node* root) {
Node* curr = root;
while (curr != NULL) {
cout << curr->reg<<curr->cg << " ";
curr = curr->next;
}
cout << endl;
}
int main() {
Node* root = NULL;
root = InsertAtBegin(root,66,4.00);
root = InsertAtBegin(root, 33,3.90);
root = InsertAtBegin(root,45,3.80);
Print(root);
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgpzdHJ1Y3QgTm9kZSB7CiAgICBpbnQgcmVnOwpmbG9hdCBjZzsKICAgIE5vZGUqIG5leHQ7Cn07CgoKTm9kZSogSW5zZXJ0QXRCZWdpbihOb2RlKiByb290LCBpbnQgcmVnLGZsb2F0IGNnKSB7CiAgICBOb2RlKiBuZXdub2RlID0gbmV3IE5vZGUoKTsKICAgIG5ld25vZGUtPnJlZz1yZWc7Cm5ld25vZGUtPmNnPWNnOwogICAgbmV3bm9kZS0+bmV4dCA9IHJvb3Q7CmlmKHJvb3Q9PU5VTEwpCnsKcm9vdD1uZXdub2RlOwpyZXR1cm4gcm9vdDsKfQplbHNlCnsKbmV3bm9kZS0+bmV4dD1yb290Owpyb290PW5ld25vZGU7CnJldHVybiByb290Owp9Cn0KCgoKdm9pZCBQcmludChOb2RlKiByb290KSB7CiAgICBOb2RlKiBjdXJyID0gcm9vdDsKICAgIHdoaWxlIChjdXJyICE9IE5VTEwpIHsKICAgICAgICBjb3V0IDw8IGN1cnItPnJlZzw8Y3Vyci0+Y2cgPDwgIiAiOwogICAgICAgIGN1cnIgPSBjdXJyLT5uZXh0OwogICAgfQogICAgY291dCA8PCBlbmRsOwp9CgppbnQgbWFpbigpIHsKICAgIE5vZGUqIHJvb3QgPSBOVUxMOwoKICAgIAogICAgcm9vdCA9IEluc2VydEF0QmVnaW4ocm9vdCw2Niw0LjAwKTsKICAgIHJvb3QgPSBJbnNlcnRBdEJlZ2luKHJvb3QsIDMzLDMuOTApOwogICAgcm9vdCA9IEluc2VydEF0QmVnaW4ocm9vdCw0NSwzLjgwKTsKICAgIFByaW50KHJvb3QpOyAKCiAgICAKCiAgICByZXR1cm4gMDsKfQ==