| ||||||||||
| 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 | |||||||||
Re:哪位大虾给组数据啊。。一直WA----PROBLEM2934In Reply To:哪位大虾给组数据啊。。一直WA Posted by:Huacm34 at 2006-08-06 16:56:20 > #include<stdio.h>
> #include<string.h>
> char words[20000][99];
> int len[20000];
> inline void swap(char& a,char& b){
> register char c;
> c=a;
> a=b;
> b=c;
> }
> inline bool ismis(char a[],char b[]){
> int i=0,j,t;
> while(a[i]==b[i] && a[i])i++;
> j=i;
> if(a[i+1]==b[i]){
> while(a[i+1]==b[i] && b[i])i++;
> if(!a[i+1] && !b[i])return 1;
> }else if(a[i]==b[i+1]){
> while(a[i]==b[i+1] && a[i])i++;
> if(!a[i] && !b[i+1])return 1;
> }else if(a[i+1]==a[i+1]){
> i++;
> while(a[i]==b[i] && a[i])i++;
> if(!a[i] && !b[i])return 1;
> }
> i=j;
> for(j=i+1;a[j];j++){
> swap(a[i],a[j]);
> t=i;
> while(a[t]==b[t] && a[t]){
> t++;
> }
> if(!a[t] && !b[t]){
> swap(a[i],a[j]);
> return 1;
> }
> swap(a[i],a[j]);
> }
> return 0;
> }
> int main(){
> int n,t,i,l,tmp;
> char bu[99];
> do{
> gets(bu);
> }while(!bu[0]);
> sscanf(bu,"%d",&n);
> for(i=0;i<n;i++){
> do{
> gets(words[i]);
> }while(!words[i][0]);
> len[i]=strlen(words[i]);
> }
> do{
> gets(bu);
> }while(!bu[0]);
> sscanf(bu,"%d",&t);
> init:while(t--){
> do{
> gets(bu);
> }while(!bu[0]);
> l=strlen(bu);
> for(i=0;i<n;i++){
> if(len[i]!=l)continue;
> if(!strcmp(bu,words[i])){
> printf("%s is correct\n",bu);
> goto init;
> }
> }
> for(i=0;i<n;i++){
> tmp=len[i]-l+1;
> if(tmp>=0 && tmp<=2){
> if(ismis(words[i],bu)){
> printf("%s is a misspelling of %s\n",bu,words[i]);
> goto init;
> }
> }
> }
> printf("%s is unknown\n",bu);
> }
> return 0;
> }
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator