文章标题
来源:互联网 发布:空电脑怎么装系统 知乎 编辑:程序博客网 时间:2024/05/17 22:26
描述
编写一个函数,计算字符串中含有的不同字符的个数。字符在ACSII码范围内(0~127)。不在范围内的不作统计。
知识点 字符串,函数,指针
运行时间限制 10M
内存限制 128
输入
输入N个字符,字符在ACSII码范围内(0~127)。
输出
输出字符的个数。
样例输入 abc
样例输出 3
#include<iostream> #include<vector> #include<string> #include<algorithm> #include<cmath> #include<unordered_map>using namespace std;int main(){ string s; getline(cin, s); int a[128] = { 0 }; for (int i = 0; i < s.size(); i++){ a[s[i]]++; } int cnt = 0; for (int i = 0; i < 128; i++){ if (a[i] != 0) cnt++; } cout << cnt << endl; return 0;}
#include<iostream> #include<vector> #include<string> #include<algorithm>#include<cmath>using namespace std;int main(){ string s; getline(cin, s); sort(s.begin(), s.end()); string::const_iterator it =unique(s.begin(), s.end()); s.erase(it,s.end()); cout << s.size(); return 0;}
0 0
- 文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题 文章标题 文章标题 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 一道程序题
- 学习笔记——Maven pom.xml配置详解
- LeetCode 2 -Add Two Numbers
- mysql权限管理
- 算法导论 练习题 2.1-4
- 文章标题
- 干货:解码OneData,阿里的数仓之路。
- 日常发题
- 程序中的数学表达式
- 【图像特征提取1】方向梯度直方图HOG---从理论到实践------附带积分图像的解析
- 最小值到最大值的随机数
- 基于How To Tango With Django 1.9的重新实践(8)——Templates
- 【阿里云网站日志分析实践】通过Log Service日志服务导入MaxCompute分析
- 学习笔记——Maven超级POM