i before asked for help in my c++ problem and every one told me i have to do more effort so that might help me with it.
please guys here is what i have reached and note that i dont have the visual studio 6 on my pc.
i wrote this on text so check for me...but i cant write it with using splice() fuction or write list so help me with it plz....the program was :

Description:

Declare the following two integer lists:
int a[] = {5, 8, 4, 1, 7}, b[] = {12, 3, 15, 6, 23, 1, 2};
int sizeA = sizeof(a)/sizeof(int), sizeB = sizeof(b)/sizeof(int);
list<int> list1(a, a+sizeA), list2(b, b+sizeB);
Use the function splice() from the library "d_list1.h" to copy list2 onto the end of list1.
Use writeList() to output list1.

and that is all i can do:

#include<iostream.h>
main()
{

   int a[]={5,8,4,1,7};
   int b[]={12,3,15,6,23,1,2};
   int i;
   int sizeA,sizeB,temp;


   for(i=0;i<5;i++)
   {
      temp=a[i];
      sizeA=a[i]/2;
      temp=temp+sizeA;
      a[i]=temp;
    }

   for(i=0;i<5;i++)
   {
      temp=a[i];
      sizeB=b[i]/2;
      temp=temp+sizeB;
      b[i]=temp;
    }
"splice() as guessed
  for(i=0;i<7;i++)
  a[5+i]=b[i];

"write list() as i guessed
  for(i=0;i<12;i++)
 cout<<a[i];

}

Edited 1 Year Ago by Dani: Formatting fixed

Declare the following two integer lists:
int a[] = {5, 8, 4, 1, 7}, b[] = {12, 3, 15, 6, 23, 1, 2};
int sizeA = sizeof(a)/sizeof(int), sizeB = sizeof(b)/sizeof(int);
list<int> list1(a, a+sizeA), list2(b, b+sizeB);
Use the function splice() from the library "d_list1.h" to copy list2 onto the end of list1.
Use writeList() to output list1.

Its pretty much been coded FOR YOU!

int a[] = {5, 8, 4, 1, 7}, b[] = {12, 3, 15, 6, 23, 1, 2}; // lists declared
int sizeA = sizeof(a)/sizeof(int), sizeB = sizeof(b)/sizeof(int); // list sizes
list<int> list1(a, a+sizeA), list2(b, b+sizeB); // i think this is correct, assuming it is given to you correct....

// unless you need PURE stl declaration

vector<int> list1; // mental block: forgot the size contructor :(
vector<int> list2; // mental block: forgot the size contructor :(

Suggests that the code will do what is required. Then you seem to need to use the 'splice' function in that header to merge the lists...? what is the problem ?? Look up the function itself and see if you can work out how to use it :)

What is the code you created doing anyway? it makes no mathematical sense!

This article has been dead for over six months. Start a new discussion instead.