zoukankan      html  css  js  c++  java
  • Codeforces Round #253 (Div. 2)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
    


    就是查字母种类数 大水题

    #include <iostream>
    #include <cstring>
    using namespace std;
    const int inf=0x3f3f3f3f;
    int main()
    {
        int a[30];
        string s;
        getline(cin,s);
        memset(a,0,sizeof(a));
        for(int i=0;i<s.size();i++)
        {
            if(s[i]>='a'&&s[i]<='z')
                a[s[i]-'a']++;
        }
        int ans=0;
        for(int i=0;i<26;i++)
            if(a[i])
            ans++;
        cout<<ans<<endl;
        return 0;
    }
    



  • 相关阅读:
    C++ 内存分配(new,operator new)详解
    单例
    实现sizeof
    muduo学习一:简介
    虚函数可以是内联函数吗?
    C++多态实现机制
    [转] Android 开源框架Universal-Image-Loader完全解析(一)--- 基本介绍及使用
    [Android]实现客户端之间的即时通信
    android获取手机通讯录
    java中forName()的作用
  • 原文地址:https://www.cnblogs.com/liguangsunls/p/6912479.html
Copyright © 2011-2022 走看看