A. Anton and Letters

A. Anton and Letters

大家好,又见面了,我是全栈君,祝每个程序员都可以多学几门语言。

time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

Recently, Anton has found a set. The set consists of small English letters. Anton carefully wrote out all the letters from the set in one line, separated by a comma. He also added an opening curved bracket at the beginning of the line and a closing curved bracket at the end of the line.

Unfortunately, from time to time Anton would forget writing some letter and write it again. He asks you to count the total number of distinct letters in his set.

Input

The first and the single line contains the set of letters. The length of the line doesn’t exceed 1000. It is guaranteed that the line starts from an opening curved bracket and ends with a closing curved bracket. Between them, small English letters are listed, separated by a comma. Each comma is followed by a space.

Output

Print a single number — the number of distinct letters in Anton’s set.

Sample test(s)
input
{a, b, c}

output
3

input
{b, a, b, a}

output
2

input
{}

output
0

解题说明:此题事实上就是考察C++中的set,把输入处理好就可以。

#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include <set>
using namespace std;

int main()
{
	string s;
	set<char> t;
	while (cin>>s)
	{
		if (s[0]!='{') 
		{
			t.insert(s[0]);
		}
		else if (s[1]!='}')
		{
			t.insert(s[1]);
		}
	}
	cout<<t.size()<<endl;
	return 0;
}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/118633.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • qq视频资源是什么_qq代码视频教程

    qq视频资源是什么_qq代码视频教程QQ视频资源裂变源码有哪些功能对于2021年网赚引流最快变现的一些思路qq资源!已解锁全部!点击进入观赏!这个是分享以后得卡片标题内容这个系统有2个版本,第一调用单个视频资源链接(支持mp4,m3u8格式),第二个版本支持观看10-60秒后强制分享弹窗下上图片位置带自定义图片广告跳转,跳转链接可批量留多个裂变网页链接达到裂变式框架“`…

    2022年8月24日
    11
  • python hashlib安装_Hashlib加密,内置函数,安装操作数据库「建议收藏」

    python hashlib安装_Hashlib加密,内置函数,安装操作数据库「建议收藏」hashlib模块的md5加密:md5同样的内容加密后是一样的md5加密后是不可逆的。即能加密,没办法解密。撞库:只是针对简单的,因为同样的内容加密后是一样的,难一点就不行了。登录密码:注册时候加密了保存,在登录时再加密,对比加密后内容一致即符合条件登录加盐:目的是增加复杂性。在该加密的内容上,再加上定好的一段儿内容,一同加密。在加上的这段内容,就是1importhashlib2#impor…

    2022年5月31日
    307
  • 更改host文件_添加host文件

    更改host文件_添加host文件修改host文件来访问GitHub

    2022年10月12日
    2
  • layui vue 在一起用的坑 select

    layui vue 在一起用的坑 select问题是这样的,<divclass=”layui-btn-group”><buttonclass=”layui-btn”@click=”businessChange(‘bc01′)”:class=”business==’bc01′?’layui-btn-normal’:’layui-btn-primary’…

    2022年6月25日
    24
  • Hi3516DV300开发板——2.uboot、kernel、fs文件系统烧写

    Hi3516DV300开发板——2.uboot、kernel、fs文件系统烧写前言搭建环境教程:Hi3516DV300开发板——1.环境搭建此教程默认环境:Win10+VMware+Ubuntu18.04这篇文章只针对使用Windows下使用网口进行烧录,所以需要有一根网线和一根串口线直连电脑。不要问为什么不用串口,因为我之前串口烧录了2个小时还没成功,最后网口1分半钟烧录成功,至于官方提供的vscode,对serialport太不好装了,果断放弃。百度云过期可以留邮箱发需要哪个@@@@烧写准备1.安装USB转串口的驱动程序链接:USB-to-SerialC

    2022年9月23日
    2
  • python3.8安装scrapy_python没安装成功怎么办

    python3.8安装scrapy_python没安装成功怎么办直接安装scrapy各种报错,后来各种百度终于解决了,如下是亲身的经历。pipinstallscrapy这样直接会报错。第一步:先安装wheelpipinstallwheel第二步:安装twiste,事先下载好Twisted-17.9.0-cp36-cp36m-win32.whl,我用的是32位,切换到twisted路径下安装,这上有http://www.lfd.uci.edu/~g…

    2022年9月18日
    3

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号