Advertisement
sajib581

dimik 16 with test case loop

Apr 10th, 2019
708
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. void print_reverse(char pq[]){
  4. int i;
  5. for(i=strlen(pq)-1;i>=0;i--){
  6. printf("%c",pq[i]);
  7. }
  8. }
  9. int main(){
  10. char ab[1000],str[1000];
  11. int T,i,j,x,limit,length,temp=0,k,t=0 ;
  12. printf("Enter test case : ");
  13. scanf("%d",&T);
  14. for(x=0;x<T;x++){
  15. scanf(" %[^\n]",ab);
  16. length=strlen(ab);
  17. for(i=0;i<length;i++){
  18. limit=i-temp ;
  19. if(ab[i]==' '){
  20. for(j=0;j<limit ;j++){
  21. str[j]=ab[temp] ;
  22. temp++ ;
  23. }
  24. str[j++ ]='\0';
  25. print_reverse(str) ;
  26. printf(" ");
  27. temp ++ ;
  28. }
  29. if(length == i+1){
  30. for(k=i;ab[k]!=' ';k--){
  31. str[t]=ab[k];
  32. t++ ;
  33.  
  34. }
  35. str[t]='\0' ;
  36. printf("%s",str);
  37. printf("\n") ;
  38.  
  39. }
  40. }
  41. }
  42.  
  43. return 0 ;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement