Monday, 17 July 2017

pangrams


Roy wanted to increase his typing speed for programming contests. So, his friend advised him to type the sentence "The quick brown fox jumps over the lazy dog" repeatedly, because it is a pangram. (Pangrams are sentences constructed by using every letter of the alphabet at least once.)
After typing the sentence several times, Roy became bored with it. So he started to look for other pangrams.
Given a sentence , tell Roy if it is a pangram or not.


#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>

int main() {
    //int test ;
    //scanf("%d",&test);
   
    //while(test)
    {
        char s[1000];
        gets(s);int flag;
        for(char m = 'A'; m <='Z';m++)
        {
            for (int arr_i=0;arr_i<strlen(s);arr_i++)
            {
                if ((s[arr_i]==m)||((s[arr_i])==(m+32)))
                {
                    flag=1;
                    //printf("%c",s[arr_i]);
                    break;
                   
                }
                if (arr_i==(strlen(s)-1))
                {
                    flag =0;
                }
            }
            if (flag ==0)
            {
                break;
            }
        }
        if (flag ==1){
            printf("pangram");}
        else
        {printf("not pangram");}
      //  test--;
    }
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */
    return 0;
}

No comments:

Post a Comment