题解 | #字符串反转#
名字的漂亮度
http://www.nowcoder.com/practice/02cb8d3597cf416d9f6ae1b9ddc4fde3
https://www.nowcoder.com/ #include<stdio.h> #include<string.h> int main() { int n; int i,j,k; int len;
int temp,count;
char str1[10000];
scanf("%d",&n);
for(i=0;i<n;i++){ count=0; int b[30]={0}; scanf("%s",&str1); len=strlen(str1); for(j=0;j<26;j++) for(k=0;k<len;k++) if(str1[k]==97+j||str1[k]==65+j) b[j]++; for(j=0;j<25;j++) for(k=0;k<25-j;k++) { if(b[k]<b[k+1]) { temp=b[k]; b[k]=b[k+1]; b[k+1]=temp; } } for(j=0;j<26;j++) count=count+b[j]*(26-j); printf("%d\n",count); } }