Advertisement
Guest User

Untitled

a guest
Dec 6th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main()
  5. {
  6. char strok[100];
  7. char strok1[100];
  8. char strokk[100];
  9. fgets(strok,100,stdin);
  10. strcpy(strok1, strok);
  11. char ans[30];
  12. char *io=strtok(strok1," ");
  13. strcpy(ans,io);
  14.  
  15. while (io!= NULL && io[0]!="."){
  16. strcpy(ans,io);
  17. io=strtok(NULL," ");
  18. }
  19. strok[strlen(strok)-1]=' ';
  20. int len=0;
  21. char *chh=strtok(strok," ");
  22.  
  23. char u;
  24. strcpy(strok1, chh);
  25. if (strcmp(strok1, ans ) != 0){
  26. strcpy(strokk, chh);
  27. u=strokk[0];
  28. if (strokk[strlen(strokk)-1]!='.'){
  29. strokk[0]=strokk[strlen(strokk)-1];
  30. strokk[strlen(strokk)-1]=u;
  31. strcat(strokk, " ");
  32. len+=strlen(strokk);
  33. }
  34. }
  35.  
  36. while (chh!=NULL){
  37. chh=strtok(NULL, " ");
  38. if (chh!=NULL){
  39. strcpy(strok1, chh);
  40. if (strcmp(strok1, ans ) != 0){
  41.  
  42.  
  43. strcat(strokk, chh);
  44. if (strokk[strlen(strokk)-1]!='.')
  45. {
  46. u=strokk[len];
  47. strokk[len]=strokk[strlen(strokk)-1];
  48. strokk[strlen(strokk)-1]=u;
  49. strcat(strokk," ");
  50. }
  51. len=strlen(strokk);
  52. }
  53.  
  54. if (strokk[len-1]=='.'){
  55. strokk[len-1]=' ';
  56. strokk[len-2]='.';
  57. }
  58. }
  59. }
  60.  
  61. fputs(strokk,stdout);
  62.  
  63. return 0;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement