Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
请大家帮忙看看为什么是output limit exceed#include <stdio.h> #include <stdlib.h> #include <string.h> double key(char a){ if(a<='z'&&a>='a') return a-'a'+1; else return a-'A'+0.5; } int compare(const void *p, const void *q){ if(key(*(char*)p)>key(*(char*)q)) return 1; else if(key(*(char*)p)<key(*(char*)q)) return -1; else return 0; } int n, k, t; char s[14], pr[14]; bool use[14]; void print(){ int i; if(k==0) printf("%s\n", pr); else{ for(i=0; i<n; i++){ if(!use[i]&&(i==0||s[i]!=s[i-1]||use[i-1])){ pr[t]=s[i]; use[i]=true; t++; k--; print(); k++; t--; use[i]=false; } } } } int main(){ int i; scanf("%d", &n); while(n--){ scanf("%s", s); n=(int)strlen(s); for(i=0; i<n; i++) use[i]=false; qsort(s, n, sizeof(char), compare); t=0; pr[n]='\0'; k=n; print(); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator