char n[1000]; int main(t,i,j,l) { while(~scanf("%d%s%d",&l,n,&t)) { for(i=0;i<abs(t);i++) if(t>0) printf("%s",n); else for(j=l-1;j>-1;j--) printf("%c",n[j]); puts(""); } }
Note that non-ascii characters in the above source code will be escaped (such as \x9f).