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


相关推荐

  • java老版手机游戏合集激活成功教程

    java老版手机游戏合集激活成功教程一、前言最近刚读完一本书:《Netty、Zookeeper、Redis并发实战》,个人觉得Netty部分是写得很不错的,读完之后又对Netty进行了一波很好的复习(之前用springboot+netty+zookeeper模仿dubbo做rpc框架,那时候是刚学netty后自己造的小轮子)。虽然对于Netty的使用已经比较熟悉了,而且还知道它的底层是基于JavaNIO做进一步的封装,使得并发性能和开发效率得到大大的提升。但是,对于同步阻塞、同步非阻塞、异步这

    2022年7月7日
    22
  • 常用数据库端口号总结

    关系型数据库:1.Oracle数据库默认端口号为,1521;2.MySQL数据库默认端口号为,3306;3.SQLServer数据库默认端口号为,1433;4.postgreSQL数据库默认端口号为,5432;NOSQL数据库:1.MongoDB默认端口号为:27017;2.Redis默认端口号为:6379;3.memcached默认端口号为:11211;…

    2022年4月6日
    121
  • pyzharm激活码_通用破解码

    pyzharm激活码_通用破解码,https://javaforall.net/100143.html。详细ieda激活码不妨到全栈程序员必看教程网一起来了解一下吧!

    2022年3月17日
    52
  • 电力负荷预测三篇综述总结

    电力负荷预测三篇综述总结对前面三篇关于负荷预测的综述论文进行一个总结。

    2022年5月9日
    410
  • webstorm2021激活码【2021最新】

    (webstorm2021激活码)2021最新分享一个能用的的激活码出来,希望能帮到需要激活的朋友。目前这个是能用的,但是用的人多了之后也会失效,会不定时更新的,大家持续关注此网站~IntelliJ2021最新激活注册码,破解教程可免费永久激活,亲测有效,下面是详细链接哦~https://javaforall.net/100143.html…

    2022年3月22日
    97
  • AutoSize

    AutoSizeLabel1->AutoSize=False;//TrueLabel1->Caption=”Thisstringistoolongtobethecaptionofthislabel”;通过为知笔记发布转载于:https://www.cnblogs.com/xe2011/archive/2012/06/03/5e3ea26bf00c3f837…

    2022年6月6日
    24

发表回复

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

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