Advertisement
gosuodin

lap3

Sep 14th, 2016
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4.  
  5. struct node{
  6. int heso;
  7. int somu;
  8. node*pNext;
  9.  
  10.  
  11. };
  12. struct list{
  13. node*pHead;
  14. int size;
  15. };
  16. list*ConvertTolinkerList(int *arr, int size){
  17. list *l=new list;
  18. node*a;
  19. int i=0;
  20. l->pHead->heso=arr[0];
  21. while(i!=size){
  22. a=new node;
  23. a=l->pHead->pNext;
  24. a->heso=arr[i];
  25. while(a->pNext!=NULL){
  26. l->pHead=a;
  27. }
  28. }
  29. }
  30. void Print(list*&l){
  31. while(l->pHead->pNext!=NULL){
  32. cout << l->pHead->heso;
  33. l->pHead=l->pHead->pNext;
  34. }
  35. }
  36. int main(){
  37.  
  38. int arr[5]={3,4,5,6,5};
  39. list*linkerlist=ConvertTolinkerList(arr,5);
  40. Print(linkerlist);
  41.  
  42.  
  43. system("pause");
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement