zoukankan      html  css  js  c++  java
  • Codeforces Round #295 (Div. 2)——A——Pangram

    A word or a sentence in some language is called a pangram if all the characters of the alphabet of this language appear in it at least once. Pangrams are often used to demonstrate fonts in printing or test the output devices.

    You are given a string consisting of lowercase and uppercase Latin letters. Check whether this string is a pangram. We say that the string contains a letter of the Latin alphabet if this letter occurs in the string in uppercase or lowercase.

    Input

    The first line contains a single integer n (1 ≤ n ≤ 100) — the number of characters in the string.

    The second line contains the string. The string consists only of uppercase and lowercase Latin letters.

    Output

    Output "YES", if the string is a pangram and "NO" otherwise.

    Sample test(s)
    input
    12
    toosmallword
    output
    NO
    input
    35
    TheQuickBrownFoxJumpsOverTheLazyDog
    output
    YES
    大意:只要简单排序,统计与原来字母表多少一样的就行
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    using namespace std;
    int main()
    {
        char s[105],s2[30] = {"abcdefghijklmnopqrstuvwxyz"};
        int n;
        while(~scanf("%d",&n)){
                getchar();
                scanf("%s",s);
                for(int i = 0; i < n ; i++)
                        if(s[i] >='A'&&s[i] <= 'Z')
                         s[i] = s[i] - 'A' + 'a';
                sort(s,s+n);
               int count = 0;
               for(int i = 0; i < n ; i++){
                    if(s[i] == s2[count])
                    count++;
               }
               if(count == 26)
                printf("YES
    ");
               else printf("NO
    ");
        }
        return 0;
    }
    View Code
     
  • 相关阅读:
    zip压缩类
    sqlserver配置允许快照隔离
    (三)装饰模式
    (二)策略模式
    (一)简单工厂模式
    MFC中lib和dll的区别
    VC MFC工具栏(CToolBar)控件(非常重要)
    CMFCMenuBar和CMFCToolBar相同ID,在显示不同标签文字
    CImageList类Create函数参数解析
    c++连接数据库代码
  • 原文地址:https://www.cnblogs.com/zero-begin/p/4350026.html
Copyright © 2011-2022 走看看