#include
(5570)#include
int main()
{
int i,j,k,n,s,tmp,len;
char str[10000];
while(scanf("&d",&n)!=EOF)
{
for(k=0;k {
scanf("%s",&str);
len=strlen(str);
int ha[26]={0};
for(i=0;i {
if(str[i]>='A'&& str[i]<='Z')
{ha[str[i]-'A']++;}
else
{ha[str[i]-'a']++;}
}
for(i=0;i<25;i++)
{
for(j=0;j<25-i;j++)
{
if(ha[j] {
tmp=ha[j];
ha[j]=ha[j+1];
ha[j+1]=tmp;
}
}
}
s=0;
for(i=0;i<26;i++)
{
s+=(ha[i]*(26-i));
}
printf("%d\n",s);
}
}
}
运行超时了怎么办?
(5570)#include
int main()
{
int i,j,k,n,s,tmp,len;
char str[10000];
while(scanf("&d",&n)!=EOF)
{
for(k=0;k
scanf("%s",&str);
len=strlen(str);
int ha[26]={0};
for(i=0;i
if(str[i]>='A'&& str[i]<='Z')
{ha[str[i]-'A']++;}
else
{ha[str[i]-'a']++;}
}
for(i=0;i<25;i++)
{
for(j=0;j<25-i;j++)
{
if(ha[j]
tmp=ha[j];
ha[j]=ha[j+1];
ha[j+1]=tmp;
}
}
}
s=0;
for(i=0;i<26;i++)
{
s+=(ha[i]*(26-i));
}
printf("%d\n",s);
}
}
}
运行超时了怎么办?
「求助大佬帮看看这道算法题吧!」 给出一个名字,该名字有26个字符串组成,定义这个字符串的“漂亮度”是其所有字母“漂亮度”的总和。 每个字母都有一个“漂亮度”,范围在1到26之间。没有任何两个字母拥有相同的“漂亮度”。字母忽略大小写...
https://gw-c.nowcoder.com/api/sparta/jump/link?link=https%3A%2F%2Fwww.nowcoder.com%2FquestionTerminal%2F02cb8d3597cf416d9f6ae1b9ddc4fde3
全部评论
相关推荐
点赞 评论 收藏
分享
![](https://static.nowcoder.com/fe/file/oss/1716965564844UEBJN.png)
![](https://static.nowcoder.com/fe/file/oss/1716965585666UBBME.png)
OPPO
| 校招
| 超多精选岗位
点赞 评论 收藏
分享
点赞 评论 收藏
分享