Shamba

soluchan 2

Feb 20th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include <iostream>
  2. #include<stdio.h>
  3. #include<string.h>
  4.  
  5. using namespace std;
  6. void reverse_words(char abc[200])
  7. {
  8.     int i,s,a=0,l;
  9.     l=strlen(abc);
  10.     for(i=0;i<=l;i++)
  11.     {
  12.         if((abc[i]==' ') || (abc[i]=='\0'))
  13.         {
  14.             for(s=i;s>=a;s--)
  15.             {
  16.                 cout<<abc[s];
  17.             }
  18.             a=i;
  19.         }
  20.     }
  21. }
  22.  
  23. int main()
  24. {
  25.     char a[200];
  26.     cout<<"Enter the string : ";
  27.     gets(a);
  28.     reverse_words(a);
  29.     return 0;
  30. }
Add Comment
Please, Sign In to add comment