zoukankan      html  css  js  c++  java
  • Codeforces Round #253 (Div. 2) A. Anton and Letters

    Codeforces Round #253 (Div. 2)

    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
    output
    input
    output
    input
    output
    0
    
     1 #include<iostream>  
     2 #include<string.h>  
     3 #include<stdio.h>  
     4 #include<ctype.h>  
     5 #include<algorithm>  
     6 #include<stack>  
     7 #include<queue>  
     8 #include<set>  
     9 #include<math.h>  
    10 #include<vector>  
    11 #include<map>  
    12 #include<deque>  
    13 #include<list>  
    14 using namespace std;
    15 int v[10000];
    16 int main()
    17 {
    18     memset(v,0,sizeof(v));
    19     char s[10000];
    20     int ans=0;
    21     gets(s);
    22     int n=strlen(s);
    23     for(int i=0;i<n;i++)
    24     if(s[i]>'A'&&s[i]<'Z')
    25     {
    26         int u=s[i]-'A';
    27         if(v[u]==0)
    28         {
    29             ans++;
    30             v[u]=1;
    31         }
    32     }
    33     cout<<ans;
    34 } 
    View Code

  • 相关阅读:
    编译原理:算符优先分析
    编译原理:自下而上语法分析
    编译原理:实验二 递归下降语法分析
    编译原理:LL(1)文法的判断,递归下降分析程序
    作业9 DFA最小化
    作业8 非确定的自动机NFA确定化为DFA
    作业7 正规式到正规文法与自动机
    作业6 正规文法与正规式
    作业5 词法分析程序的设计与实现
    作业4 文法和语言总结与梳理
  • 原文地址:https://www.cnblogs.com/qscqesze/p/3896557.html
Copyright © 2011-2022 走看看