Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

sample过,可是那出错 WA,附代码,有注释

Posted by Manio at 2006-01-20 17:48:40 on Problem 1171
/*找出SCORE 的函数*/
int findscr(char str[])
{

  int i=0;
  int score=0;
  while(str[i]!='\0'){
      switch(str[i])
      {
        case 'e' :
        case 'i' :
        case 's' :score+=1;break;
        case 'r' :
        case 't' :
        case 'a' :
        case 'n' :score+=2;break;
        case 'o' :
        case 'l' :score+=3;break;
        case 'u' :
        case 'd' :
        case 'c' :score+=4;break;
        case 'y' :
        case 'p' :
        case 'g' :
        case 'h' :
        case 'b' :
        case 'm' :score+=5;break;
        case 'w' :
        case 'f' :
        case 'k' :
        case 'v' :score+=6;break;
        case 'q' :
        case 'z' :
        case 'x' :
        case 'j' :score+=7;break;
      }/*switch*/
      i++;
  } /*while*/
return score;
}

/*whether all letter in dictionary is org[] */
int check(char strOrg[] , char strDic[])
{
  int i=0,j=0;
  
  while( strDic[i] != '\0' ){
    j = 0;
    while( strOrg[j] != '\0' ){
      if(strDic[i] == strOrg[j]){
         strOrg[j]='8';
         break;                           /*如果有相同的了,就把相同的那个从COLLECTED LETTER里去掉,并跳出内层的WHILE*/
         }
     j++;        
    }
    if(strOrg[j] == '\0')return 0;         /*因为有相同的必然会跳出来,所以如果比到最后的/0了,必然是没有相同的*/
  i++;
  } 
  
return 1;
}/*check*/

/*给字符串赋值*/
void letequal(char str1[],char str2[])
{
int i=0;
while( (str1[i] = str2[i]) != '\0' )i++;

}


main()
{
 int findscr(char str[]);
 int max = 0;
 char org[30],dic[30],orgfc[30];

 scanf("%s",org);
 letequal(orgfc,org);


/*input dictionary*/

 scanf("%s",dic);
 while( dic[0]!='.' ){
   letequal(orgfc,org);
   if( check(orgfc,dic) && max < findscr(dic) )max = findscr(dic);
   scanf("%s",dic);
  }/*while*/

printf("%d",max);


}/*main*/


Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator