Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdlib>
- #include <iostream>
- using namespace std;
- struct List{
- int value;
- List *next;
- };
- void DeleteList(){
- }
- void PrintList(List **begin){
- List *tmp = (*begin);
- cout << "\n";
- while(tmp){
- cout << tmp->value << " -> ";
- tmp = tmp->next;
- }
- }
- void InitList(List **node, int count){
- (*node) = new List;
- (*node)->next = NULL;
- List *tmp = *node;
- cout << "\nVvedite element: ";
- cin >> tmp->value;
- for(int i=1;i<count;i++){
- tmp->next = new List;
- tmp = tmp->next;
- cout << "\nVvedite element: ";
- cin >> tmp->value;
- tmp->next = NULL;
- }
- }
- int main() {
- List *head_1 = new List;
- head_1->next = NULL;
- int count;
- cout << " Vvedite kolichestvo elementov\n";
- cin >> count;
- InitList(&head_1,count);
- List *head_2 = new List;
- List *tmp1 = head_1;
- List *tmp2 = head_2;
- int number_of_node;
- do{
- cout << "\nVvedite chislo dla vtorovo spiska: ";
- cin >> number_of_node;
- }while((number_of_node < 0) || (number_of_node > count));
- for(int i=0;i<number_of_node-1;i++){
- tmp1 = tmp1->next;
- }
- tmp2->value = tmp1->value;
- tmp1 = tmp1->next;
- while(tmp1){
- tmp2->next = new List;
- tmp2 = tmp2->next;
- tmp2->value = tmp1->value;
- tmp1 = tmp1->next;
- }
- PrintList(&head_2);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement