Saturday, June 18, 2011

[Cpp-Programming] Aw: string reverse function strrev() not present in GNU C

depending on what you're doing and if you're working with std:string I suggest you check out std::string::rbegin and std::string::rend or std::reverse from <algorithm>

--
You received this message because you are subscribed to the Google Groups "C++ Programming" group.
To view this discussion on the web visit https://groups.google.com/d/msg/cpp-programming/-/i5iFi-mFpEAJ.
To post to this group, send email to cpp-programming@googlegroups.com.
To unsubscribe from this group, send email to cpp-programming+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cpp-programming?hl=en.

[Cpp-Programming] string reverse function strrev() not present in GNU C

I unfortunately found that GNU C compiler doesn't have strrev() function which is used to reverse a string.
What should I do.. Can you provide a function which does this job.

--
You received this message because you are subscribed to the Google Groups "C++ Programming" group.
To view this discussion on the web visit https://groups.google.com/d/msg/cpp-programming/-/AhTvCrPSLZoJ.
To post to this group, send email to cpp-programming@googlegroups.com.
To unsubscribe from this group, send email to cpp-programming+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cpp-programming?hl=en.

Wednesday, June 15, 2011

Re: [Cpp-Programming] Digest for cpp-programming@googlegroups.com - 2 Messages in 1 Topic

java?, of course! The fool son of C++ ....

Welcome to C++


2011/6/15 Fernando Garcia <ferngarcia.fg@gmail.com>:
> Are you talking to me?
> I am from argentina and i love JAVA
>
> 2011/6/15 <cpp-programming+noreply@googlegroups.com>
>>
>>   Today's Topic Summary
>>
>> Group: http://groups.google.com/group/cpp-programming/topics
>>
>> problem during runtime [2 Updates]
>>
>>  Topic: problem during runtime
>>
>> upashu2 <upashu1@rediffmail.com> Jun 13 10:52PM -0700 ^
>>
>> Integer is overflowing. take double and modified ur code accordingly.
>>
>>
>>
>>
>> BlueRaja <blueraja.admin@gmail.com> Jun 14 11:26AM -0500 ^
>>
>> If your requirements allow it, using gmp (http://gmplib.org/) would be the
>> best solution.
>>
>> Otherwise, I suggest you become very friendly with your debugger - seeing
>> the values of each variable as each line of code is executed will tell you
>> exactly where something isn't behaving as you expected it to.
>>
>> The debugger in Visual Studio is built in; a tutorial can be found here (
>> http://www.cprogramming.com/tutorial/debugging_concepts.html) - skim
>> through
>> parts 1 and 2, part 3 is the important part.
>> If you are using gcc, the debugger is called gdb, and is more difficult to
>> use. A tutorial can be found here (http://www.cs.cmu.edu/~gilpin/tutorial/
>> ).
>> Debugging in most other IDEs is similar to Visual Studio, though you may
>> want to use google to find a tutorial for your specific IDE.
>>
>> Good luck!
>>
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "C++ Programming" group.
>> To post to this group, send email to cpp-programming@googlegroups.com.
>> To unsubscribe from this group, send email to
>> cpp-programming+unsubscribe@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/cpp-programming?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "C++ Programming" group.
> To post to this group, send email to cpp-programming@googlegroups.com.
> To unsubscribe from this group, send email to
> cpp-programming+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/cpp-programming?hl=en.
>

--
You received this message because you are subscribed to the Google Groups "C++ Programming" group.
To post to this group, send email to cpp-programming@googlegroups.com.
To unsubscribe from this group, send email to cpp-programming+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cpp-programming?hl=en.

Re: [Cpp-Programming] Digest for cpp-programming@googlegroups.com - 2 Messages in 1 Topic

Are you talking to me?
I am from argentina and i love JAVA

2011/6/15 <cpp-programming+noreply@googlegroups.com>

Group: http://groups.google.com/group/cpp-programming/topics

    upashu2 <upashu1@rediffmail.com> Jun 13 10:52PM -0700 ^
     
    Integer is overflowing. take double and modified ur code accordingly.
     

     

    BlueRaja <blueraja.admin@gmail.com> Jun 14 11:26AM -0500 ^
     
    If your requirements allow it, using gmp (http://gmplib.org/) would be the
    best solution.
     
    Otherwise, I suggest you become very friendly with your debugger - seeing
    the values of each variable as each line of code is executed will tell you
    exactly where something isn't behaving as you expected it to.
     
    The debugger in Visual Studio is built in; a tutorial can be found here (
    http://www.cprogramming.com/tutorial/debugging_concepts.html) - skim through
    parts 1 and 2, part 3 is the important part.
    If you are using gcc, the debugger is called gdb, and is more difficult to
    use. A tutorial can be found here (http://www.cs.cmu.edu/~gilpin/tutorial/
    ).
    Debugging in most other IDEs is similar to Visual Studio, though you may
    want to use google to find a tutorial for your specific IDE.
     
    Good luck!

     

--
You received this message because you are subscribed to the Google Groups "C++ Programming" group.
To post to this group, send email to cpp-programming@googlegroups.com.
To unsubscribe from this group, send email to cpp-programming+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cpp-programming?hl=en.

--
You received this message because you are subscribed to the Google Groups "C++ Programming" group.
To post to this group, send email to cpp-programming@googlegroups.com.
To unsubscribe from this group, send email to cpp-programming+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cpp-programming?hl=en.

Tuesday, June 14, 2011

Re: [Cpp-Programming] Re: problem during runtime

If your requirements allow it, using gmp (http://gmplib.org/) would be the best solution.

Otherwise, I suggest you become very friendly with your debugger - seeing the values of each variable as each line of code is executed will tell you exactly where something isn't behaving as you expected it to.

The debugger in Visual Studio is built in; a tutorial can be found here (http://www.cprogramming.com/tutorial/debugging_concepts.html) - skim through parts 1 and 2, part 3 is the important part.
If you are using gcc, the debugger is called gdb, and is more difficult to use.  A tutorial can be found here (http://www.cs.cmu.edu/~gilpin/tutorial/).
Debugging in most other IDEs is similar to Visual Studio, though you may want to use google to find a tutorial for your specific IDE.

Good luck!

--
You received this message because you are subscribed to the Google Groups "C++ Programming" group.
To post to this group, send email to cpp-programming@googlegroups.com.
To unsubscribe from this group, send email to cpp-programming+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cpp-programming?hl=en.

Monday, June 13, 2011

[Cpp-Programming] Re: problem during runtime

Integer is overflowing. take double and modified ur code accordingly.

On Jun 3, 2:02 pm, Deepak <deepakkushwah2...@gmail.com> wrote:
> hi
> there is a problem of finding the factorial of no upto 100 now we
> don't have any variable to store that amount of data
> so i'm considering an array of 200 elements inwhich each element
> contains the digits of final ans
> for example   720    will be stored as a[0]=0     a[1]=2     a[2]=7
> given below  is it's program  but it is not giving the correct ans
> after 10
> help me if u can find any bug in this program
>
> #include<iostream>
> using namespace std;
> int main()
> {
>     cout<<"enter the no of test cases:"<<endl;
>     int t;
>     int num;
>     cin>>t;
>      int a[200];             //array to accomodate the digits of the
> factorial
>      for(int i=0;i<t;i++)         //this loop will run for all the
> test cases
>      {
>              a[0]=1;                     //initialising the array with
> a[0]=1 and rest all the elements 0
>           for(int i=1;i<=199;i++)
>              {
>              a[i]=0;
>              }
>            int temp=0;
>             int m=1;                   //carry the no. of elements in
> the array occupied during factorial computation
>             cout<<"enter the no"<<endl;
>            cin>>num;                 // the no. of which we have to
> find the factorial
>            for(int j=1;j<=num;j++)
>            {
>                    for(int k=0;;k++)
>                    {
>                           int x=a[k]*j+temp;
>                           a[k]=x%10;
>                           temp=x/10;
>                           if(temp==0 && a[k+1]==0) break;
>
>                           if(a[k+1]==0)m++;
>                    }
>            }
>            for(int i=m-1;i>=0;i--)
>            {
>                    cout<<a[i];
>            }
>            cout<<endl;
>      }
>     system("pause");
>
>
>
>
>
>
>
> }

--
You received this message because you are subscribed to the Google Groups "C++ Programming" group.
To post to this group, send email to cpp-programming@googlegroups.com.
To unsubscribe from this group, send email to cpp-programming+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cpp-programming?hl=en.

Friday, June 03, 2011

[Cpp-Programming] problem during runtime

hi
there is a problem of finding the factorial of no upto 100 now we
don't have any variable to store that amount of data
so i'm considering an array of 200 elements inwhich each element
contains the digits of final ans
for example 720 will be stored as a[0]=0 a[1]=2 a[2]=7
given below is it's program but it is not giving the correct ans
after 10
help me if u can find any bug in this program


#include<iostream>
using namespace std;
int main()
{
cout<<"enter the no of test cases:"<<endl;
int t;
int num;
cin>>t;
int a[200]; //array to accomodate the digits of the
factorial
for(int i=0;i<t;i++) //this loop will run for all the
test cases
{
a[0]=1; //initialising the array with
a[0]=1 and rest all the elements 0
for(int i=1;i<=199;i++)
{
a[i]=0;
}
int temp=0;
int m=1; //carry the no. of elements in
the array occupied during factorial computation
cout<<"enter the no"<<endl;
cin>>num; // the no. of which we have to
find the factorial
for(int j=1;j<=num;j++)
{
for(int k=0;;k++)
{
int x=a[k]*j+temp;
a[k]=x%10;
temp=x/10;
if(temp==0 && a[k+1]==0) break;

if(a[k+1]==0)m++;
}
}
for(int i=m-1;i>=0;i--)
{
cout<<a[i];
}
cout<<endl;
}
system("pause");
}

--
You received this message because you are subscribed to the Google Groups "C++ Programming" group.
To post to this group, send email to cpp-programming@googlegroups.com.
To unsubscribe from this group, send email to cpp-programming+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cpp-programming?hl=en.

[Cpp-Programming] problem during runtime

hi
there is a problem of finding the factorial of no upto 100 now we
don't have any variable to store that amount of data
so i'm considering an array of 200 elements inwhich each element
contains the digits of final ans
for example 720 will be stored as a[0]=0 a[1]=2 a[2]=7
given below is it's program but it is not giving the correct ans
after 10
help me if u can find any bug in this program


#include<iostream>
using namespace std;
int main()
{
cout<<"enter the no of test cases:"<<endl;
int t;
int num;
cin>>t;
int a[200]; //array to accomodate the digits of the
factorial
for(int i=0;i<t;i++) //this loop will run for all the
test cases
{
a[0]=1; //initialising the array with
a[0]=1 and rest all the elements 0
for(int i=1;i<=199;i++)
{
a[i]=0;
}
int temp=0;
int m=1; //carry the no. of elements in
the array occupied during factorial computation
cout<<"enter the no"<<endl;
cin>>num; // the no. of which we have to
find the factorial
for(int j=1;j<=num;j++)
{
for(int k=0;;k++)
{
int x=a[k]*j+temp;
a[k]=x%10;
temp=x/10;
if(temp==0 && a[k+1]==0) break;

if(a[k+1]==0)m++;
}
}
for(int i=m-1;i>=0;i--)
{
cout<<a[i];
}
cout<<endl;
}
system("pause");
}

--
You received this message because you are subscribed to the Google Groups "C++ Programming" group.
To post to this group, send email to cpp-programming@googlegroups.com.
To unsubscribe from this group, send email to cpp-programming+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cpp-programming?hl=en.

Re: [Cpp-Programming] i'm facing

thank you saurabh
i know this is one of the solution but i was not able to find the
correct reason for that


On 6/3/11, saurabh jain <mail2saurabh.jain@gmail.com> wrote:
> I think to have the highest possibility of selection you would want to stay
> in the queue as long as possible. One of the way I think is ,
>
> If you know the number of men , find the maximum power of 2 which is less
> than n and choose that position for you. That ways you will always be in
> even position until the end.
>
> For example , suppose you have 50 men to start with, choose 32 as your
> position
> 50 men, position 32
> ==> 25 men, position 16
> ==> 12 men, position 8
> ==> 6 men, position 4
> ==> 3 men, position 2
> ==> 1 men , position 1 ==> selected :)
>
> Saurabh
>
> On Fri, Jun 3, 2011 at 12:20 AM, DEEPAK KUSHWAH <deepakkushwah2302@gmail.com
>> wrote:
>
>> hi praveen,
>> that is to be given by the user
>>
>> On 6/2/11, Praveen Nuthulapati <praveen2k4@gmail.com> wrote:
>> > Hi Deepak,
>> > how many crew is the captain selecting ?
>> >
>> > do you get a array out of bounds error?
>> >
>> > Praveen
>> >
>> > On Thu, Jun 2, 2011 at 10:18 AM, Deepak <deepakkushwah2302@gmail.com>
>> wrote:
>> >> below is a code chef problem:
>> >> The captain of the ship TITANIC is a little .... off the track. He
>> >> needs to select the crew for the ship. But everyone seems to be
>> >> eligible. So to test their intelligence, he plays a game.
>> >> The contestants have to stand in a line. They are given the numbers in
>> >> the order in which they stand, starting from 1. The captain then
>> >> removes all the contestants that are standing at an odd position.
>> >> Initially, standing people have numbers - 1,2,3,4,5...
>> >> After first pass, people left are - 2,4,...
>> >> After second pass - 4,....
>> >> And so on.
>> >> You want to board the ship as a crew member. Given the total number of
>> >> applicants for a position, find the best place to stand in the line so
>> >> that you are selected.
>> >>
>> >>
>> >> i've done it by taking an array and eliminating the nos recursively
>> >> but it is saying time limit exceeded
>> >> can u please tell me the optimized algorithm for such problem
>> >>
>> >> --
>> >> You received this message because you are subscribed to the Google
>> Groups
>> >> "C++ Programming" group.
>> >> To post to this group, send email to cpp-programming@googlegroups.com.
>> >> To unsubscribe from this group, send email to
>> >> cpp-programming+unsubscribe@googlegroups.com.
>> >> For more options, visit this group at
>> >> http://groups.google.com/group/cpp-programming?hl=en.
>> >>
>> >>
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "C++ Programming" group.
>> > To post to this group, send email to cpp-programming@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > cpp-programming+unsubscribe@googlegroups.com.
>> > For more options, visit this group at
>> > http://groups.google.com/group/cpp-programming?hl=en.
>> >
>> >
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "C++ Programming" group.
>> To post to this group, send email to cpp-programming@googlegroups.com.
>> To unsubscribe from this group, send email to
>> cpp-programming+unsubscribe@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/cpp-programming?hl=en.
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "C++ Programming" group.
> To post to this group, send email to cpp-programming@googlegroups.com.
> To unsubscribe from this group, send email to
> cpp-programming+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/cpp-programming?hl=en.
>
>

--
You received this message because you are subscribed to the Google Groups "C++ Programming" group.
To post to this group, send email to cpp-programming@googlegroups.com.
To unsubscribe from this group, send email to cpp-programming+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cpp-programming?hl=en.

Thursday, June 02, 2011

Re: [Cpp-Programming] i'm facing


I think to have the highest possibility of selection you would want to stay in the queue as long as possible. One of the way I think is ,

If you know the number of men , find the maximum power of 2 which is less than n and choose that position for you. That ways you will always be in even position until the end.

For example , suppose you have 50 men to start with, choose 32 as your position
50 men, position 32
==> 25 men, position 16
==> 12 men, position 8
==> 6 men, position 4
==> 3 men, position 2
==> 1 men , position 1 ==> selected :)

Saurabh

On Fri, Jun 3, 2011 at 12:20 AM, DEEPAK KUSHWAH <deepakkushwah2302@gmail.com> wrote:
hi praveen,
that is to be given by the user

On 6/2/11, Praveen Nuthulapati <praveen2k4@gmail.com> wrote:
> Hi Deepak,
> how many crew is the captain selecting ?
>
> do you get a array out of bounds error?
>
> Praveen
>
> On Thu, Jun 2, 2011 at 10:18 AM, Deepak <deepakkushwah2302@gmail.com> wrote:
>> below is a code chef problem:
>> The captain of the ship TITANIC is a little .... off the track. He
>> needs to select the crew for the ship. But everyone seems to be
>> eligible. So to test their intelligence, he plays a game.
>> The contestants have to stand in a line. They are given the numbers in
>> the order in which they stand, starting from 1. The captain then
>> removes all the contestants that are standing at an odd position.
>> Initially, standing people have numbers - 1,2,3,4,5...
>> After first pass, people left are - 2,4,...
>> After second pass - 4,....
>> And so on.
>> You want to board the ship as a crew member. Given the total number of
>> applicants for a position, find the best place to stand in the line so
>> that you are selected.
>>
>>
>> i've done it by taking an array and eliminating the nos recursively
>> but it is saying time limit exceeded
>> can u please tell me the optimized algorithm for such problem
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "C++ Programming" group.
>> To post to this group, send email to cpp-programming@googlegroups.com.
>> To unsubscribe from this group, send email to
>> cpp-programming+unsubscribe@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/cpp-programming?hl=en.
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "C++ Programming" group.
> To post to this group, send email to cpp-programming@googlegroups.com.
> To unsubscribe from this group, send email to
> cpp-programming+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/cpp-programming?hl=en.
>
>

--
You received this message because you are subscribed to the Google Groups "C++ Programming" group.
To post to this group, send email to cpp-programming@googlegroups.com.
To unsubscribe from this group, send email to cpp-programming+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cpp-programming?hl=en.


--
You received this message because you are subscribed to the Google Groups "C++ Programming" group.
To post to this group, send email to cpp-programming@googlegroups.com.
To unsubscribe from this group, send email to cpp-programming+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cpp-programming?hl=en.

Re: [Cpp-Programming] i'm facing

hi praveen,
that is to be given by the user

On 6/2/11, Praveen Nuthulapati <praveen2k4@gmail.com> wrote:
> Hi Deepak,
> how many crew is the captain selecting ?
>
> do you get a array out of bounds error?
>
> Praveen
>
> On Thu, Jun 2, 2011 at 10:18 AM, Deepak <deepakkushwah2302@gmail.com> wrote:
>> below is a code chef problem:
>> The captain of the ship TITANIC is a little .... off the track. He
>> needs to select the crew for the ship. But everyone seems to be
>> eligible. So to test their intelligence, he plays a game.
>> The contestants have to stand in a line. They are given the numbers in
>> the order in which they stand, starting from 1. The captain then
>> removes all the contestants that are standing at an odd position.
>> Initially, standing people have numbers - 1,2,3,4,5...
>> After first pass, people left are - 2,4,...
>> After second pass - 4,....
>> And so on.
>> You want to board the ship as a crew member. Given the total number of
>> applicants for a position, find the best place to stand in the line so
>> that you are selected.
>>
>>
>> i've done it by taking an array and eliminating the nos recursively
>> but it is saying time limit exceeded
>> can u please tell me the optimized algorithm for such problem
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "C++ Programming" group.
>> To post to this group, send email to cpp-programming@googlegroups.com.
>> To unsubscribe from this group, send email to
>> cpp-programming+unsubscribe@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/cpp-programming?hl=en.
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "C++ Programming" group.
> To post to this group, send email to cpp-programming@googlegroups.com.
> To unsubscribe from this group, send email to
> cpp-programming+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/cpp-programming?hl=en.
>
>

--
You received this message because you are subscribed to the Google Groups "C++ Programming" group.
To post to this group, send email to cpp-programming@googlegroups.com.
To unsubscribe from this group, send email to cpp-programming+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cpp-programming?hl=en.

Re: [Cpp-Programming] i'm facing

Hi Deepak,
how many crew is the captain selecting ?

do you get a array out of bounds error?

Praveen

On Thu, Jun 2, 2011 at 10:18 AM, Deepak <deepakkushwah2302@gmail.com> wrote:
> below is a code chef problem:
> The captain of the ship TITANIC is a little .... off the track. He
> needs to select the crew for the ship. But everyone seems to be
> eligible. So to test their intelligence, he plays a game.
> The contestants have to stand in a line. They are given the numbers in
> the order in which they stand, starting from 1. The captain then
> removes all the contestants that are standing at an odd position.
> Initially, standing people have numbers - 1,2,3,4,5...
> After first pass, people left are - 2,4,...
> After second pass - 4,....
> And so on.
> You want to board the ship as a crew member. Given the total number of
> applicants for a position, find the best place to stand in the line so
> that you are selected.
>
>
> i've done it by taking an array and eliminating the nos recursively
> but it is saying time limit exceeded
> can u please tell me the optimized algorithm for such problem
>
> --
> You received this message because you are subscribed to the Google Groups "C++ Programming" group.
> To post to this group, send email to cpp-programming@googlegroups.com.
> To unsubscribe from this group, send email to cpp-programming+unsubscribe@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/cpp-programming?hl=en.
>
>

--
You received this message because you are subscribed to the Google Groups "C++ Programming" group.
To post to this group, send email to cpp-programming@googlegroups.com.
To unsubscribe from this group, send email to cpp-programming+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cpp-programming?hl=en.

[Cpp-Programming] i'm facing

below is a code chef problem:
The captain of the ship TITANIC is a little .... off the track. He
needs to select the crew for the ship. But everyone seems to be
eligible. So to test their intelligence, he plays a game.
The contestants have to stand in a line. They are given the numbers in
the order in which they stand, starting from 1. The captain then
removes all the contestants that are standing at an odd position.
Initially, standing people have numbers - 1,2,3,4,5...
After first pass, people left are - 2,4,...
After second pass - 4,....
And so on.
You want to board the ship as a crew member. Given the total number of
applicants for a position, find the best place to stand in the line so
that you are selected.


i've done it by taking an array and eliminating the nos recursively
but it is saying time limit exceeded
can u please tell me the optimized algorithm for such problem

--
You received this message because you are subscribed to the Google Groups "C++ Programming" group.
To post to this group, send email to cpp-programming@googlegroups.com.
To unsubscribe from this group, send email to cpp-programming+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/cpp-programming?hl=en.