Tuesday, July 28, 2009

I dont know y i m getting wrong answer?

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 %26lt;stdio.h%26gt;


#include %26lt;stdlib.h%26gt;


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-%26gt;word,word);


node-%26gt;link=NULL;


return node;


}


ptr insert(ptr list,char *word){


ptr node;


node=creat(word);


node-%26gt;link=list;


return node;


}


inorder(ptr list,int n){


int i;


ptr phead,temp;





phead=list;


for(i=1;i%26lt;n;i++){


temp=list;


list=list-%26gt;link;


}


printf("%s",list-%26gt;word);


if(n%26gt;1){


temp-%26gt;link=list-%26gt;link;


list=insert(phead,list-%26gt;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",%26amp;t)!=EOF %26amp;%26amp; t!='0'){


if(isalpha(t)){word[p++]=t; printf("%c",t); s=1;}


else if(t%26gt;=48 %26amp;%26amp; t%26lt;58){ k=1; n*=10; n+=t-48; }


else{


if(!k %26amp;%26amp; 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;


}

I dont know y i m getting wrong answer?
i think it would help if you said what it is you are trying to do in the first place, and what is failing.


No comments:

Post a Comment