#include<stdio.h>
#include<stdlib.h>
#include<string.h>
void Swap(char *a,char *b)
{
char c;
c=*a;
*a=*b;
*b=c;
}
int main()
{
char input[100];
printf("Enter a string (Length < 100) : ");
scanf("%[^\n]",input);
//Reversing the string
int len=strlen(input);
int i=0,j=len-1;
while(i < j)
{
Swap(input+i,input+j);
i++;
j--;
}
//Reversing the Words.
i=0,j=0;
while(input[j] != '\0')
{
if(input[j] == ' ')
{
int k= j-1;
while(i < k)
{
Swap(input+i,input+k);
i++;
k--;
}
i=++j;
continue;
}
j++;
}
printf("%s",input);
printf("\n\n");
system("pause");
}
Sanju
:)
On Tue, Sep 13, 2011 at 2:35 AM, shashi kant <[email protected]> wrote:
> hey Karthik phodd diya yaar tune .........tejas waale cha gaye
>
> On Tue, Sep 13, 2011 at 3:02 PM, kARTHIK R <[email protected]> wrote:
>
>> Something like this.
>>
>>
>> stack<char *> S;
>> void function(char *s) {
>> char *ptr=s;
>> while(*ptr++ !=' ') {}
>> *ptr = '\0';
>> S.push(s); // Will push the string till NULL into
>> the stack
>> function(ptr+1);
>> }
>>
>>
>> // Pop from stack to get words
>>
>> Karthik R
>>
>>
>>
>> On Tue, Sep 13, 2011 at 2:50 PM, guna sekaran <[email protected]> wrote:
>>
>>> please write a code any one
>>>
>>> On Tue, Sep 13, 2011 at 2:06 PM, shady <[email protected]> wrote:
>>> > search archives, already done
>>> >
>>> > On Tue, Sep 13, 2011 at 1:39 PM, Anshul Khandelwal
>>> > <[email protected]> wrote:
>>> >>
>>> >> U can take command line argument in main
>>> >> main(int argc,char * argv[ ])
>>> >> { for(i=argc-1,i>=0;i--) printf("%s ",argv[i]);
>>> >> }
>>> >>
>>> >>
>>> >> On Tue, Sep 13, 2011 at 12:05 AM, hary rathor <[email protected]
>>> >
>>> >> wrote:
>>> >>>
>>> >>> kapil : in your solution you are required extra O(n+n*sizeOf(int *))
>>> both
>>> >>> memory to create a link list that really costly
>>> >>>
>>> >>>
>>> >>> --
>>> >>> You received this message because you are subscribed to the Google
>>> Groups
>>> >>> "Algorithm Geeks" group.
>>> >>> To post to this group, send email to [email protected].
>>> >>> To unsubscribe from this group, send email to
>>> >>> [email protected].
>>> >>> For more options, visit this group at
>>> >>> http://groups.google.com/group/algogeeks?hl=en.
>>> >>
>>> >>
>>> >>
>>> >> --
>>> >> Regards
>>> >> ANSHUL KHANDELWAL
>>> >> Final year
>>> >> Computer Engineering
>>> >> NIT Jaipur
>>> >>
>>> >>
>>> >> --
>>> >> You received this message because you are subscribed to the Google
>>> Groups
>>> >> "Algorithm Geeks" group.
>>> >> To post to this group, send email to [email protected].
>>> >> To unsubscribe from this group, send email to
>>> >> [email protected].
>>> >> For more options, visit this group at
>>> >> http://groups.google.com/group/algogeeks?hl=en.
>>> >
>>> > --
>>> > You received this message because you are subscribed to the Google
>>> Groups
>>> > "Algorithm Geeks" group.
>>> > To post to this group, send email to [email protected].
>>> > To unsubscribe from this group, send email to
>>> > [email protected].
>>> > For more options, visit this group at
>>> > http://groups.google.com/group/algogeeks?hl=en.
>>> >
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Algorithm Geeks" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected].
>>> For more options, visit this group at
>>> http://groups.google.com/group/algogeeks?hl=en.
>>>
>>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Algorithm Geeks" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> *Shashi Kant *
> ***"Think positive and find fuel in failure"*
> *+917259733668
> *
> *R&D engineer ,
> Tejas Networks Ltd Banglore.
> *
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.