Algorithm


beecrowd | 1050

DDD

Adapted by Neilor Tonin, URI Brazil

Timelimit: 1

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.

Input Sample Output Sample

11

Sao Paulo

Code Examples

#1 Code Example with C Programming

Code - C Programming



#include <stdio.h>

    int main() {
        int a;
        scanf("%i", &a);
        if(a == 61){
            printf("Brasilia\n");
        } else if(a == 71){
            printf("Salvador\n");
        } else if(a == 11){
            printf("Sao Paulo\n");
        } else if(a == 21){
            printf("Rio de Janeiro\n");
        } else if(a == 32){
            printf("Juiz de Fora\n");
        } else if(a == 19){
            printf("Campinas\n");
        } else if(a == 27){
            printf("Vitoria\n");
        } else if(a == 31){
            printf("Belo Horizonte\n");
        } else{
            printf("DDD nao cadastrado\n");
        }
        return 0;
    }
Copy The Code & Try With Live Editor

Input

x
+
cmd
11

Output

x
+
cmd
Sao Paulo

#2 Code Example with C++ Programming

Code - C++ Programming

s

#include <iostream>
using namespace std;

int main(){
    int a;
    cin >> a;
    switch(a){
        case 11:
            cout << "Sao Paulo\n";
            break;
        case 19:
            cout << "Campinas\n";
            break;
        case 21:
            cout << "Rio de Janeiro\n";
            break;
        case 27:
            cout << "Vitoria\n";
            break;
        case 31:
            cout << "Belo Horizonte\n";
            break;
        case 32:
            cout << "Juiz de Fora\n";
            break;
        case 61:
            cout << "Brasilia\n";
            break;
        case 71:
            cout << "Salvador\n";
            break;
        default:
            cout << "DDD nao cadastrado\n";
            break;   
        } 
        return 0;     
    }
Copy The Code & Try With Live Editor

Input

x
+
cmd
11

Output

x
+
cmd
Sao Paulo

#3 #3 Code Example with Another C++ Programming

Code - C++ Programming


#include <cstdio>
int main()
{
 int a;
 scanf("%i", &a);

 if(a == 61){
        printf("Brasilia\n");
 } else if(a == 71){
        printf("Salvador\n");
 }else if(a == 11){
        printf("Sao Paulo\n");
 } else if(a == 21){
        printf("Rio de Janeiro\n");
 } else if(a == 32){
        printf("Juiz de Fora\n");
 } else if(a == 19){
        printf("Campinas\n");
 } else if(a == 27){
        printf("Vitoria\n");
 } else if(a == 31){
        printf("Belo Horizonte\n");
 } else{
        printf("DDD nao cadastrado\n");
 }
    return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
11

Output

x
+
cmd
Sao Paulo

#4 Code Example with Java Programming

Code - Java Programming


import java.util.Scanner;

public class URI_1050 {
    public static void main(String[] args) {
        int a;
        Scanner sc = new Scanner(System.in);
        a = sc.nextInt();

        if(a == 61){
            System.out.printf("Brasilia\n");
        } else if(a == 71){
            System.out.printf("Salvador\n");
        } else if(a == 11){
            System.out.printf("Sao Paulo\n");
        } else if(a == 21){
            System.out.printf("Rio de Janeiro\n");
        } else if(a == 32){
            System.out.printf("Juiz de Fora\n");
        } else if(a == 19){
            System.out.printf("Campinas\n");
        } else if(a == 27){
            System.out.printf("Vitoria\n");
        } else if(a == 31){
            System.out.printf("Belo Horizonte\n");
        } else{
            System.out.printf("DDD nao cadastrado\n");
        }

    }

}

Copy The Code & Try With Live Editor

Input

x
+
cmd
11

Output

x
+
cmd
Sao Paulo

#5 Code Example with Python Programming

Code - Python Programming


entrada = int(raw_input())

if(entrada == 61):
    print "Brasilia"
elif(entrada == 71):
    print "Salvador"
elif(entrada == 11):
    print "Sao Paulo"
elif(entrada == 21):
    print "Rio de Janeiro"
elif(entrada == 32):
    print "Juiz de Fora"
elif(entrada == 19):
    print "Campinas"
elif(entrada == 27):
    print "Vitoria"
elif(entrada == 31):
    print "Belo Horizonte"
else:
    print "DDD nao cadastrado"

Copy The Code & Try With Live Editor

Input

x
+
cmd
11

Output

x
+
cmd
Sao Paulo
Advertisements

Demonstration


Previous
#1049 Beecrowd Online Judge Solution 1049 Animal Solution in C++, Java, Js and Python
Next
#1051 Beecrowd Online Judge Solution 1051 Taxes- Solution in C, C++, Java, Python and C#