mringg的天空,自由,自在  
日历
<2024年4月>
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011
统计
  • 随笔 - 6
  • 文章 - 0
  • 评论 - 0
  • 引用 - 0

导航

常用链接

留言簿

随笔分类

随笔档案

相册

搜索

  •  

最新评论

阅读排行榜

评论排行榜

 
 1#include <iostream>
 2#include <string>
 3using namespace std;
 4int main()
 5{
 6    string word;
 7    int zero=0;
 8    int abc[26]={};
 9    cin>>word;
10    for (int i=0;i<word.size();i++)
11    {
12        ++abc[word[i]-'a'];
13    }

14    int maxword=-1,minword=999999;
15    for (int i=0;i<26;i++)
16    {
17        if (abc[i]>maxword) maxword=abc[i];
18    }

19    for (int i=0;i<26;i++)
20    {
21        if (abc[i]<minword&&abc[i]!=0) minword=abc[i];
22    }

23    int cha;
24    cha=maxword-minword;
25    if (cha==2||cha==3||cha==5||cha==7||cha==11||cha==13||cha==17||cha==19||cha==23||cha==29||cha==31||cha==37||cha==41||cha==43||cha==47||cha==53)
26    {
27       cout<<"Lucky Word"<<endl;
28       cout<<cha<<endl;
29    }

30    else
31    {
32        cout<<"No Answer"<<endl;
33        cout<<zero<<endl;
34    }

35    system ("pause");
36    return 0;
37}

38
posted on 2010-02-09 15:57 mringg 阅读(601) 评论(0)  编辑 收藏 引用 所属分类: NOIP题解

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


 
Copyright © mringg Powered by: 博客园 模板提供:沪江博客