Sample Input
Dear Sally,
Please, please do it--1 would 4
Mary very, 1 much. And 4 6
8 everything in 5's power to make
14 pay off for you.
-- Thank 2 18 18--
0
Sample Output
Dear Sally,
Please, please do it--it would please
Mary very, very much. And Mary would
do everything in Mary's power to make
it pay off for you.
/*Uncompress*/
#include
#include
typedef struct listnode *ptr;
typedef struct listnode{
char word[50];
ptr link;
};
ptr creat(char *word){
ptr node;
node=malloc(sizeof(struct listnode));
strcpy(node->word,word);
node->link=NULL;
return node;
}
ptr insert(ptr list,char *word){
ptr node;
node=creat(word);
node->link=list;
return node;
}
inorder(ptr list,int n){
int i;
ptr phead,temp;
phead=list;
for(i=1;i
temp=list;
list=list->link;
}
printf("%s",list->word);
if(n>1){
temp->link=list->link;
list=insert(phead,list->word);
}
return list;
}
int main()
{
int p=0,k=0,s=0,n=0;
char t,word[50];
ptr list;
list=creat(" ");
while(scanf("%c",&t)!=EOF && t!='0'){
if(isalpha(t)){word[p++]=t; printf("%c",t); s=1;}
else if(t>=48 && t<58){ k=1; n*=10; n+=t-48; }
else{
if(!k && s){word[p]='\0'; list=insert(list,word); p=0; s=0; printf("%c",t);}
else if(k){list=inorder(list,n);k=0... n=0; printf("%c",t);}
else printf("%c",t);
}
}
return 0;
}
2006-10-27
06:03:11
·
1 answers
·
asked by
murtuzashareef2000
1