Advertisement
Guest User

Untitled

a guest
Feb 20th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. strsort(char s[], int length)
  4. {
  5.  
  6. char tmp;
  7. int i, j;
  8. for(i=0; i<length-2; i=i+2)
  9. {
  10. for (j=i+2; j<length; j=j+2)
  11. {
  12. if (s[i] > s[j])
  13. {
  14. tmp=s[i];
  15. s[i]=s[j];
  16. s[j]=tmp;
  17. }
  18. }
  19. }
  20.  
  21. for(i=1; i<length-3; i=i+2)
  22. {
  23. for (j=i+2; j<length-1; j=j+2)
  24. {
  25. if (s[i] > s[j])
  26. {
  27. tmp=s[i];
  28. s[i]=s[j];
  29. s[j]=tmp;
  30. }
  31. }
  32. }
  33. }
  34.  
  35. int main()
  36. {
  37.  
  38. int N;
  39. scanf("%d",&N);
  40. int I=0;
  41. int charCount[26];
  42. int i=0;
  43. int n;
  44. char x[212];
  45. char V[] = {'A', 'U', 'E', 'O', 'I'};
  46. char C[] = {'J', 'S', 'B', 'K', 'T', 'C', 'L', 'D', 'M', 'V', 'N', 'W', 'F', 'X', 'G', 'P', 'Y', 'H', 'Q', 'Z', 'R'};
  47.  
  48. int vc, cc;
  49. int t=1;
  50.  
  51.  
  52. for(I=0;I<N;I++)
  53. {
  54. scanf("%d", &n);
  55. i=0;
  56. for(i=0;i<26;i++)
  57. {
  58. if((i + 'A' -'A')==0 || (i + 'A' -'E')==0 || (i + 'A' -'I')==0 || (i + 'A' -'O')==0 || (i + 'A' -'U')==0)
  59. {
  60. charCount[i] = 21;
  61. }
  62. else
  63. charCount[i] = 5;
  64. }
  65.  
  66. int count = 0;
  67. vc = 0;
  68. cc = 0;
  69. t=1;
  70. printf("Case %d:",I+1);
  71. for(i=0;i<n;i++)
  72. {
  73. if(t==1)
  74. {
  75. x[count++] = V[vc];
  76. charCount[V[vc]-'A']--;
  77. if(charCount[V[vc]-'A']==0)
  78. vc++;
  79. t = t * -1;
  80. }
  81. else
  82. {
  83. x[count++] = C[cc];
  84. charCount[C[cc]-'A']--;
  85. if(charCount[C[cc]-'A']==0)
  86. cc++;
  87. t = t * -1;
  88. }
  89. }
  90. x[count] = '\0';
  91. strsort(x, count);
  92. printf("%s \n", x);
  93. }
  94. return 0;
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement