Thursday 28 January 2016

Solution of URI 1050 :: DDD


Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just find out the logic. If you stuck in trouble, just inform me on comment.

/**Bismillahir Rahmanir Rahim.**/

#include <stdio.h>
int main()
{
   int N;
    scanf("%d",&N);
    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("Bela Horizonte\n");
    else
        printf("DDD nao cadastrado\n");
    return 0;
}

2 comments:

  1. i did this with switch case but it is shown 10% wrong do you know why?

    ReplyDelete
    Replies
    1. Same with me. It showed 20% wrong answer but when I test my program, it gives correct output. I am confused.

      https://ideone.com/hu3hmO

      Delete

Note: only a member of this blog may post a comment.