Header Ads

Header ADS

Solution of URI 1050::DDD

Before seeing the solution make sure that you have tried enough. Don’t copy the whole code, just find out the logic. If you feel any problemyou will inform me by comment.




#include<stdio.h>
int main()
{
    int n;
    while(scanf("%d", &n)!=EOF)
    {
        if(n==61)
        {
            printf("Brasilia\n");

        }
        else if(n==71)
        {
            printf("Salvador\n");


        }
        else if(n==11)
        {
            printf("Sao Paulo\n");


        }
        else if(n==21)
        {
            printf("Rio de Janeiro\n");

        }
        else if(n==32)
        {
            printf("Juiz de Fora\n");

        }
        else if(n==19)
        {
            printf("Campinas\n");

        }
        else if(n==27)
        {
            printf("Vitoria\n");

        }
        else if(n==31)
        {
            printf("Belo Horizonte\n");

        }

        else
        {
            printf("DDD nao cadastrado\n");
        }
    }
    return 0;
}

No comments

Theme images by konradlew. Powered by Blogger.