Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdio.h"
- #include "stdlib.h"
- #include "string.h"
- int main(){
- unsigned int i = 0, len = 0, num = 0, k = 0, j = 0, a = 0, kol = 0;
- int nulls = 0, whites = 0;
- char c = 0;
- char str[2005];
- scanf("%d", &kol);
- scanf("%c", &c);
- c = 0;
- for (i = 0; i < kol; i++) {
- for (j = 0; 1; j++) {
- if (scanf("%c", &c) == EOF) {
- str[j] = '\0';
- break;
- }
- if (c < ' ' || c > 'z') {
- str[j] = '\0';
- break;
- }
- else
- str[j] = c;
- }
- len = j;
- for (j = 0; j < len; j++) {
- if (str[j] == ' ') {
- k = 0;
- do {
- k++;
- } while (str[j + k] == ' ');
- if (k > 2) {
- j = j + k - 1;
- while (k > 255) {
- printf("$%c", 255);
- k = k - 255;
- }
- if (k > 2)
- printf("$%c", k);
- else if (k == 1)
- printf(" ");
- else
- printf(" ");
- }
- else
- printf("%c", ' ');
- }
- else if (str[j] == '0') {
- k = 0;
- do {
- k++;
- } while (str[j + k] == '0');
- if (k > 2) {
- j = j + k - 1;
- while (k > 255) {
- printf("#%c", 255);
- k = k - 255;
- }
- if (k > 2)
- printf("#%c", k);
- else if (k == 1)
- printf("0");
- else
- printf("00");
- }
- else
- printf("%c", '0');
- }
- else printf("%c", str[j]);
- }
- printf("\n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement