fork download
  1. #include<bits/stdc++.h>
  2. #include<cstdio>
  3.  
  4. using namespace std;
  5.  
  6. void stand(char s,int i)
  7. {
  8. if(i==0&&s>=97)
  9. {
  10. s=s-32;
  11. cout<<s;
  12. }
  13. else if(i==0)
  14. cout<<s;
  15. else if(s>=97)
  16. cout<<s;
  17. else
  18. {
  19. s=s+32;
  20. cout<<s;
  21. }
  22. }
  23.  
  24. int main()
  25. {
  26. int t;
  27. cin>>t;
  28. getchar();
  29. while(t--)
  30. {
  31. char n[50];
  32. int i=0,s=0;
  33. fflush(stdin);
  34. cin.getline(n,50);
  35. for(i=0;i<strlen(n);i++)
  36. {
  37. if(n[i+1]==' ')
  38. s++;
  39. }
  40. //cout<<n<<"\n";
  41. if(s==0)
  42. {
  43. for(i=0;i<strlen(n);i++)
  44. stand(n[i],i);
  45.  
  46. }
  47. else if(s==1)
  48. {
  49. stand(n[0],0);
  50. cout<<". ";
  51. for(i=0;i<strlen(n);i++)
  52. {
  53. if(n[i]==' ')
  54. break;
  55. }
  56. i++;
  57. int j;
  58. for(j=i;j<strlen(n);j++)
  59. {
  60. if(j==i)
  61. stand(n[j],0);
  62. else
  63. stand (n[j],j);
  64. }
  65. }
  66. else
  67. {
  68. stand(n[0],0);
  69. cout<<". ";
  70. for(i=0;i<strlen(n);i++)
  71. {
  72. if(n[i]==' ')
  73. break;
  74. }
  75. stand(n[++i],0);
  76. cout<<". ";
  77. int j;
  78. for(;i<strlen(n);i++)
  79. {
  80. if(n[i]==' ')
  81. break;
  82. }
  83. i++;
  84. for(j=i;j<strlen(n);j++)
  85. {
  86. if(j==i)
  87. stand(n[j],0);
  88. else
  89. stand(n[j],j);
  90. }
  91.  
  92. }
  93. cout<<"\n";
  94.  
  95.  
  96. }
  97. }
Success #stdin #stdout 0s 15240KB
stdin
3
gandhi
mahatma gandhI
Mohndas KaramChand gandhi
stdout
Gandhi
M. Gandhi
M. K. Gandhi