Advertisement
Saeedsab

string

Dec 18th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. int main ()
  5. {
  6. char a[100];
  7. int i,j,k,l,w=0,c;
  8. for (i=0;i<2||a[i-1]!='.'||a[i-2]!='.';i++)
  9. scanf ("%c",&a[i]);
  10.  
  11. for (j=0;j<i;j++)
  12. {
  13. if (a[j]==' '&&a[j-1]==' ')
  14. {
  15. while (a[j]==' ')
  16. {
  17. for (k=j;k<i;k++)
  18. a[k]=a[k+1];
  19. i--;
  20. }
  21. }
  22. }
  23. if (a[0]>='a'&&a[0]<='z')
  24. a[0]-=32;
  25. for (c=1,j=0;j<i;j++)
  26. {
  27. if ((a[j]<'A'||a[j]>'z')&&(a[j]!=' '))
  28. c=0;
  29. if (a[j]==' ')
  30. {
  31. if (c==1)
  32. w++;
  33. c=1;
  34. }
  35. }
  36.  
  37. for (j=0;j<i;j++)
  38. {
  39. if (a[j]==' ')
  40. {
  41. if (a[j+1]>='a'&&a[j+1]<='z')
  42. a[j+1]-=32;
  43. }
  44. }
  45. for (j=0;j<i-2;j++)
  46. printf ("%c",a[j]);
  47. printf ("\n%d",w);
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement