Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //13.1//
- //main.cpp
- #include <stdio.h>
- #include <string.h>
- #include <stddef.h>
- int main()
- {
- int n;
- char s[101];
- scanf("%d ", &n);
- for(; n; n--)
- {
- scanf("%s", s);
- char *p, *q;
- p=strtok(s, ",");
- q=p;
- p=strtok(NULL, ",");
- int nr=0;
- while(p!=NULL && q!=NULL)
- {
- //printf("q=%s p=%s: ", q, p);
- if(strcmp(p, "0")!=0 && strcmp(p, "0")!=0)
- {
- printf("%s,", q);
- q=p;
- p=strtok(NULL, ",");
- }
- else if(strcmp(p, "0")==0)
- {
- while(strcmp(p, "0")==0 && p!=NULL)
- {
- nr++;
- p=strtok(NULL, ",");
- if(p==NULL)
- break;
- }
- printf("(%s,%d)", q, nr);
- q=p;
- p=strtok(NULL, ",");
- nr=0;
- if(q) printf(",");
- }
- }
- if(q)
- printf("%s", q);
- printf("\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement