Advertisement
Guest User

lalka

a guest
Nov 24th, 2014
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. #include "stdio.h"
  2. #include "stdlib.h"
  3. #include "string.h"
  4.  
  5. int main(){
  6. unsigned int i = 0, len = 0, num = 0, k = 0, j = 0, a = 0, kol = 0;
  7. int nulls = 0, whites = 0;
  8. char c = 0;
  9. char str[2005];
  10.  
  11. scanf("%d", &kol);
  12. scanf("%c", &c);
  13. c = 0;
  14. for (i = 0; i < kol; i++) {
  15. for (j = 0; 1; j++) {
  16. if (scanf("%c", &c) == EOF) {
  17. str[j] = '\0';
  18. break;
  19. }
  20. if (c < ' ' || c > 'z') {
  21. str[j] = '\0';
  22. break;
  23. }
  24. else
  25. str[j] = c;
  26. }
  27. len = j;
  28.  
  29. for (j = 0; j < len; j++) {
  30. if (str[j] == ' ') {
  31. k = 0;
  32. do {
  33. k++;
  34. } while (str[j + k] == ' ');
  35. if (k > 2) {
  36. j = j + k - 1;
  37. while (k > 255) {
  38. printf("$%c", 255);
  39. k = k - 255;
  40. }
  41. if (k > 2)
  42. printf("$%c", k);
  43. else if (k == 1)
  44. printf(" ");
  45. else
  46. printf(" ");
  47. }
  48. else
  49. printf("%c", ' ');
  50. }
  51. else if (str[j] == '0') {
  52. k = 0;
  53. do {
  54. k++;
  55. } while (str[j + k] == '0');
  56. if (k > 2) {
  57. j = j + k - 1;
  58. while (k > 255) {
  59. printf("#%c", 255);
  60. k = k - 255;
  61. }
  62. if (k > 2)
  63. printf("#%c", k);
  64. else if (k == 1)
  65. printf("0");
  66. else
  67. printf("00");
  68. }
  69. else
  70. printf("%c", '0');
  71. }
  72. else printf("%c", str[j]);
  73. }
  74. printf("\n");
  75. }
  76. return 0;
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement