Advertisement
Guest User

Untitled

a guest
Nov 29th, 2014
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. #include <string.h>
  5.  
  6. int main(){
  7. int i, len, N, j, x;
  8. int ch0 = 0;
  9. int ch_ = 0;
  10. char cases[1024];
  11. char str[1024];
  12.  
  13. gets(cases);
  14. N = atoi(cases);
  15. for (i = 0; i < N; i++) {
  16. gets(str);
  17. len = strlen(str);
  18. x = len;
  19. do {
  20. if (len < 255) x = len;
  21. else x = 255;
  22. for (j = 0; j < x; j++) {
  23. if (str[j] == '0') {
  24. if (ch_ == 1) {
  25. printf("%c", ' ');
  26. ch_ = 0;
  27. }
  28. else if (ch_ == 2) {
  29. printf("%c%c", ' ',' ');
  30. ch_ = 0;
  31. }
  32. else if (ch_ > 2) {
  33. printf("%c%c", '$', ch_);
  34. ch_ = 0;
  35. }
  36. ch0++;
  37. }
  38. else if (str[j] == ' ') {
  39. if (ch0 == 1) {
  40. printf("%c", '0');
  41. ch0 = 0;
  42. }
  43. else if (ch0 == 2) {
  44. printf("%c%c", '0','0');
  45. ch0 = 0;
  46. }
  47. else if (ch0 > 2) {
  48. printf("%c%c", '#','#');
  49. ch0 = 0;
  50. }
  51. ch_++;
  52. }
  53. else {
  54. if (ch_ == 1) {
  55. printf("%c", ' ');
  56. ch_ = 0;
  57. }
  58. else if (ch_ == 2) {
  59. printf("%c%c", ' ',' ');
  60. ch_ = 0;
  61. }
  62. else if (ch_ > 2) {
  63. printf("%c%c", '$', ch_);
  64. ch_ = 0;
  65. }
  66. else if (ch0 == 1) {
  67. printf("%c", '0');
  68. ch0 = 0;
  69. }
  70. else if (ch0 == 2) {
  71. printf("%c%c", '0','0');
  72. ch0 = 0;
  73. }
  74. else if (ch0 > 2) {
  75. printf("%c%c", '#','#');
  76. ch0 = 0;
  77. }
  78. ch0 = 0;
  79. ch_ = 0;
  80. printf ("%c", str[j]);
  81. }
  82. }
  83. if (ch_ == 1) {
  84. printf("%c", ' ');
  85. ch_ = 0;
  86. }
  87. else if (ch_ == 2) {
  88. printf("%c%c", ' ',' ');
  89. ch_ = 0;
  90. }
  91. else if (ch_ > 2) {
  92. printf("%c%c", '$', ch_);
  93. ch_ = 0;
  94. }
  95. else if (ch0 == 1) {
  96. printf("%c", '0');
  97. ch0 = 0;
  98. }
  99. else if (ch0 == 2) {
  100. printf("%c%c", '0','0');
  101. ch0 = 0;
  102. }
  103. else if (ch0 > 2) {
  104. printf("%c%c", '#','#');
  105. ch0 = 0;
  106. }
  107. len -= 255;
  108. } while (len > 0);
  109. printf("\n");
  110. }
  111. return 0;
  112. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement