Advertisement
jaskaran_1

roughness

Jan 2nd, 2013
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.78 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. int main()
  4. {char a[500];
  5. scanf("%[^\n]s",a);
  6. int hash1[95];
  7. int I;
  8. for(I=0;I<95;I++)
  9. hash1[I]=0;
  10. char *p=a;
  11. while(*p!='\0')
  12. {hash1[*p-32]++;
  13. p++;}
  14. int max=0,min=strlen(a);
  15. int posM,posm;
  16. for(I=0;I<95;I++)
  17.  {if(hash1[I]==0)
  18.  continue;
  19.  if(min>hash1[I])
  20.   {min=hash1[I];
  21.    posm=I;}
  22.  if(max<hash1[I])
  23.   {max=hash1[I];
  24.    posM=I;}}//computes min and max both
  25. int N;//the maximum characters that can be removed
  26. scanf("%d",&N);
  27. while(N--)
  28. {if(min==1)
  29.   hash1[posm]=0;
  30.  else
  31.   hash1[posM]--;
  32.  max=0;
  33.  min=strlen(a);
  34. for(I=0;I<95;I++)
  35.  {if(hash1[I]==0)
  36.  continue;
  37.  if(min>hash1[I])
  38.   {min=hash1[I];
  39.    posm=I;}
  40.  if(max<hash1[I])
  41.   {max=hash1[I];
  42.    posM=I;}}//computes min and max both
  43.  }
  44. printf("%d\n",max-min);
  45. return 0;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement