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)
上一篇 2021年12月3日 下午2:00
下一篇 2021年12月3日 下午2:00


相关推荐

  • 搭建Scrapy基础框架

    搭建Scrapy基础框架第一步 安装 python3 9 第二步 Anaconda

    2026年3月26日
    2
  • 回归树的原理和实现

    回归树的原理和实现文章目录分类树与回归树回归树原理介绍最小二乘回归树生成算法 CART 算法 Python 代码节点类回归树类简单的例子 Python 库分类树与回归树分类树用于分类问题 分类决策树在选取划分点 用信息熵 信息增益 或者信息增益率 或者基尼系数为标准 Classificati

    2026年3月16日
    2
  • Python ord函数

    Python ord函数2019 9 3Pythonord 函数功能描述 以一个字符 长度为 1 的字符串 作为参数 返回对应的 ASCll 数值

    2026年3月19日
    2
  • MATLAB数据导入(importdata函数)

    MATLAB数据导入(importdata函数)编写程序时 有时需要从外部读入数据 这里介绍用 importdata 函数把数据导入 MATLAB 的方法 1 加载和显示图像文件在 MATLAB 中建立一个脚本文件 内容如下 filename ming png A importdata filename image A 运行该文件 MATLAB 显示出图像文件 注意 该图像文件必须保存在当前目录 2 导入文本文件

    2026年3月20日
    2
  • jsonArray转list<map>

    jsonArray转list<map>直接转是转不了的需要先得到jsonArray循环得到jsonObject然后保存到map再添加到listList&lt;Map&lt;String,String&gt;&gt;list=newArrayList&lt;Map&lt;String,String&gt;&gt;();…

    2022年6月23日
    133
  • CSS样式表的引入方式

    CSS样式表的引入方式CSS初识CSS(CascadingStyleSheets)美化样式CSS通常称为CSS样式表或层叠样式表(级联样式表),主要用于设置HTML页面中的文本内容(字体、大小、对齐方式等)、图片的外形(宽高、边框样式、边距等)以及版面的布局等外观显示样式。CSS以HTML为基础,提供了丰富的功能,如字体、颜色、背景的控制及整体排版等CSS的优点1.内容与表现分离。2.网页的表现统一,容易修改。3.丰富的样式,使得页面布局更加灵活4.减少网页的代码量,增加网页的浏览速度。5.运用独立于页面

    2022年7月14日
    20

发表回复

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

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