At 13:40 2007-02-15, Thomas Hruska wrote:
>muhammad shahid wrote:
> > HELLO TO ALL
> > FRIENDS I AM A NEW PROGRAMMER IN C++, STUDENT OF
> > ELECTRONICS AND TELECOM ENGG.
> > MY problem(in the following program) is that i
> > want to store the values of 1starray(int 1starray[15]) into the
> > 2ndarray(2ndarray[15]) in the reverse order
> > i.e., the value at " 1starray[0]" will be equal to at "2ndarray[15]" in
> > other words values at reverse index of array.
> > i am using turbo c 3.0.
> >
> >
> > #include<iostream.h>
> > #include<conio.h>
> > void main()
> > {
> > clrscr();
> > int 1starray[15];
> > int 2ndarray[15];
> > cout<<""Enter values?\n";
> > for(int i=0;i<15;i++)
> > {
> > cin>>1starray[i];
> > }
> > HOW I DO NEXT \
> >
> >
> >
> > PLZ REPLY
> > SHAHID SHARIF
>
>1) Don't use Turbo C. Read the group welcome message and/or read Safe
>C++ Design Principles for why not.
>2) You can reverse the array this way:
>
>for (int i = 0; i < 15; i++) 2ndarray[i] = 1starray[14 - i];
ignoring the illegal names, why not use the standard library?
std::reverse_copy(1starray, 1starray+15, 2ndarray);
the library is included with the standard compilers so we don't HAVE
to write everything ourselves
>3) I was going to give an alternate Safe C++ solution here but Block<>
>is missing a natural method (Reverse() to be exact - BString has it
>though - never had a need for reversing an array).
>
>BTW, why do you need to have an array of identical elements in reverse?
> Just scanning the first array backwards is sufficient wherever you
>need the array in reverse.
>
>--
>Thomas Hruska
>CubicleSoft President
>Ph: 517-803-4197
>
>*NEW* VerifyMyPC 2.1
>Change tracking and management tool.
>Reduce tech. support times from 2 hours to 5 minutes.
>
>Free for personal use, $10 otherwise.
>http://www.CubicleSoft.com/VerifyMyPC/
>
>
>
>To unsubscribe, send a blank message to
><mailto:[EMAIL PROTECTED]>.
>Yahoo! Groups Links
>
>
>
Victor A. Wagner Jr. http://rudbek.com
The five most dangerous words in the English language:
"There oughta be a law"