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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • formatdatetime函数 mysql(date sub函数)

    formatdateTime()函数返回表达式,此表达式已被格式化为日期或时间表达式 formatdateTime(Date, [, Namedformat])允许数据类型: Namedformat 指示所使用的日期/时间格式的数值,如果省略,则使用 vbGeneralDate.NamedFormat参数的设置值如下:常数 值 描述 vbGeneralD

    2022年4月17日
  • rk3399调试ov2659(camera模块@dvp接口)–源码分析

    rk3399调试ov2659(camera模块@dvp接口)–源码分析  之前整理的“rockchipsensorcore框架”和rkisp下的v4l2框架有点像,只不过v4l2框架有点大(而且不支持摄像头热插拔)。其实接触越多Linux子系统越发觉得这些子系统处理思想大同小异。   这种"核…

    2022年6月8日
  • 10月30日 迅雷白金会员vip账号分享「建议收藏」

    10月30日 迅雷白金会员vip账号分享「建议收藏」www.91freevip,就要免费VIP网10月30日8:53更新迅雷会员VIP账号:迅雷vip账号894273128:1密码3579791迅雷vip账号juhao11:2密码19577

    2022年7月1日
  • Netron 下载链接

    Netron 下载链接https://github.com/lutzroeder/Netron

    2022年8月30日
  • 手机java程序_2020年最流行的Java开发技术

    手机java程序_2020年最流行的Java开发技术●写在前面的话●Java几乎无处不在,无论在智能手机、台式机、游戏设备还是科学超级计算机上,处处都有Java的影子。全世界有数百万的Java程序员在开发基于Java的产品。然而,如此激烈的竞争,意味着Java开发人员必须时刻保持领先地位。为此,他们必须随时了解和洞悉Java生态系统中的最新动态。Java程序员需要不断进步。在本文中,我们将讨论2020年Java开发人员需要掌握的Java最…

    2022年7月8日
  • mysql好还是oracle好_oracle优缺点

    mysql好还是oracle好_oracle优缺点Oracle与MySQL的区别以及优缺点MySQL的特点1、性能卓越,服务稳定,很少出现异常宕机;2、开放源代码无版本制约,自主性及使用成本低;3、历史悠久,社区和用户非常活跃,遇到问题及时寻求帮助;4、软件体积小,安装使用简单且易于维护,维护成本低;品牌口碑效应;5、支持多种OS,提供多种API接口,支持多种开发语言,对流行的PHP,Java很好的支持MySQL的缺点1、MySQL最大的缺点是其安全系统,主要是复杂而非标准,另外只有到调用mysqladmin来重读用户权限才会发生改变;2

    2022年9月14日

发表回复

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

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