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