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


相关推荐

  • 5G学习笔记:NSA和SA

    5G学习笔记:NSA和SA大家好,我是小枣君。第一个5G正式标准马上就要发布了,相信大家一定都在翘首企盼。之前我曾经和大家介绍过,去年12月份的时候,我们其实已经发布了“半个”5G标准。是的没错,那个时候是“非独立组网(NSA)”的5G标准。而我们现在正在等的,是“独立组网(SA)”的5G标准。关于非独立组网和独立组网,NSA和SA,虽然大家都听了很多次,但很少有人能真正搞懂它们到底是怎么…

    2025年7月31日
    5
  • ZOJ 3826 Hierarchical Notation 模拟

    ZOJ 3826 Hierarchical Notation 模拟

    2022年1月2日
    41
  • 使用Python对股票数据进行数据分析(一)-计算日线行情、5日均线、10日均线行情并显示

    使用Python对股票数据进行数据分析(一)-计算日线行情、5日均线、10日均线行情并显示使用Python对股票数据进行数据分析(一)-计算日线行情、5日均线、10日均线行情并显示各种炒股软件上可以显示各种技术指标,可以帮助投资者进行技术分析。这些股市中的这些指标都是怎么计算出来的呢?这里使用python的pandas库来进行计算。后期可能使用一些专门金融分析的库,比如talib库等进行分析。一、获取数据这里需要获取的数据是股票的日线行情,这里使用tushare进行获取,以…

    2025年7月23日
    4
  • 初中英语语法(007)-比较级·最高级

    初中英语语法(007)-比较级·最高级比较级·最高级英语句子中,将比较两个主体的方法叫做“比较句型”。其中,像“A比B更……”的表达方式称为比较级。“A是所有人中最高的”,这种表达方式称为最高级,组成句子的方式是将形容词或副词变化成比较级或最高级的形态。“他比她更高”这句话里得“更”怎么表现呢?这需要形容词按照一定规则变化。1、变化规则(1)+er/est:short-shorter-shortest(2)原形以e…

    2022年7月16日
    35
  • recvfrom函数

    recvfrom函数RECV(2) LinuxProgrammer’sManual RECV(2)NAMErecv,recvfrom,recvmsg-receiveamessagefromasocketSYNOPSIS#include<sys/types.h>#include<sys/socket.h>ssize_trecv(intsockfd,void*buf,size_tlen,intflags);

    2022年7月23日
    26
  • Linux下修改配置文件内容

    Linux下修改配置文件内容文件操作之修改配置文件内容在一些系统或者游戏运行时经常遇到一些情况需要修改一下配置文件的内容,比如游戏中任务升级了,需要修改人物等级,那么这是怎么完成的呢?好,我还是老规矩先来介绍一个函数,strstr一样的查看手册可以看到,该函数有两个参数,第一个参数要查询的字符串,第二个参数是目标子字符串,返回值是一个指针,指向子字符串的开头,如果没有那么返回NULL,什么意思呢,举个例子,比如CHINAENGLISH字符串,我要查找ENGLISH,使用strstr后,返回一个字符指针,指到E位置。好,介绍完

    2022年7月26日
    22

发表回复

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

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