upc - 2021级新生个人训练赛第44场

问题 F: Not Found

时间限制: 1.000 Sec  内存限制: 128 MB
提交 状态

题目描述

You are given a string S consisting of lowercase English letters. Find the lexicographically (alphabetically) smallest lowercase English letter that does not occur in S. If every lowercase English letter occurs in S, print None instead.

Constraints
1≤|S|≤105 (|S| is the length of string S.)
S consists of lowercase English letters.

沙拉查词翻译:

给定一个由小写英文字母组成的字符串S。查找S中不出现的最小的小写英文字母。如果每个小写英文字母都出现在S中,打印None。

约束

1≤|S|≤105 (|S|为字符串S的长度)

“S”由小写英文字母组成。

输入

Input is given from Standard Input in the following format:
S

输出

Print the lexicographically smallest lowercase English letter that does not occur in S. If every lowercase English letter occurs in S, print None instead.

样例输入 Copy

atcoderregularcontest

样例输出 Copy

b

提示

The string atcoderregularcontest contains a, but does not contain b.

# include<bits/stdc++.h>
using namespace std;
char c;
int flag;
set<char>ee;
int main(){
     while((c=getchar())!='\n'){
           ee.insert(c);//在set中输入 
      }
        char s='a';//从第一个'a'开始
        for(int t=1;t<=26;t++)//在26个字母中找 
      {
             flag=0;//用于判断 ,每次更新 
             set<char>::iterator it;//迭代器 ,set集合会自动将内部元素排好的,而且还会去重挺好用 
               for(it=ee.begin();it!=ee.end();it++){
               if(*it==s){
                   flag=1;//flag等于1就意思是找到了 
                  break;
             }
      } 
         if(flag==0)  //没找到就直接给它输出然后结束了 
      {
            cout<<(char)s;return 0;
      }
        s++;//更新下一个字母呗 
}
      
      cout<<"None";//都有了就输出none 
}

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值