[URI Online Judge] – 1050 – DDD

Read an integer number that is the code number for phone dialing. Then, print the destination according to the following table:

If the input number isn’t found in the above table, the output must be:
DDD nao cadastrado
That means “DDD not found” in Portuguese language.

Input

The input consists in a unique integer number.

Output

Print the city name corresponding to the input DDD. Print DDD nao cadastrado if doesn’t exist corresponding DDD to the typed number.

Sample Inputs Sample Outputs
11 Sao Paulo
33 DDD nao cadastrado

Solution:

#include <cstdio>
int main(){
 int d;
 scanf("%d", &d);
 if (d == 61)
 printf("Brasilia\n");
 else if (d == 71)
 printf("Salvador\n");
 else if (d == 11)
 printf("Sao Paulo\n");
 else if (d == 21)
 printf("Rio de Janeiro\n");
 else if (d == 32)
 printf("Juiz de Fora\n");
 else if (d == 19)
 printf("Campinas\n");
 else if (d == 27)
 printf("Vitoria\n");
 else if (d == 31)
 printf("Belo Horizonte\n");
 else
 printf("DDD nao cadastrado\n");
}
Advertisements

2 thoughts on “[URI Online Judge] – 1050 – DDD

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s