URI Online Judge solution | 1050 | DDD problem - Solution in C, C++, Java, Python and C sharp
URI Online Judge Solution 1050 | Data structures
URI Main Problem Link - https://www.urionlinejudge.com.br/judge/en/problems/view/1050
Problem Name: URI Problem 1050 solution
Problem Number : URI Problem 1050 Solution
Online Judge : URI Online Judge Solution
Level: Data structures
Solution Language : C, C plus plus
URI Solution 1050 Code in C:
#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;}
Tags: Uri solve , Uri solution, URI oj Solve, URI Online Judge Solution list
URI 1050 Code in C++ language using just switch case:
#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;}
The way for solving this problem in C (Simple and easy):
This is a simple program of if-else.This program will also be solved in other language like C++, Java,Python. Steps to solve the problem in C
This line is for taking a value from the user in n variable. Here, We just store the phone dialing code values.
That means if user input 61 then print Brasilia. Using same procedures check others comparisons and just print the required text. It's easy.
Step 1:
scanf("%d", &n);
This line is for taking a value from the user in n variable. Here, We just store the phone dialing code values.
Step 2:
if( n == 61 ) { printf("Brasilia\n"); }else if( n == 71 ) { printf("Salvador\n"); }
That means if user input 61 then print Brasilia. Using same procedures check others comparisons and just print the required text. It's easy.
Just try it. For more you can check these from URI forum
Tags: URI Online Judge Solution, URI OJ Solution list, URI Problems Solution, URI solver, URI all problem solution list, URI 1050 DDD code in C, URI 1050 code in C++, URI 1050 DDD solution in C, URI solution, URI 1050 Animal solution in C, URI 1050 solution in C++-CPP,URI 1050 solution in C# (C sharp),URI 1050 solution in Java,URI 1050 DDD solution in Python,
URI DDD problem solution, URI 1050 problem solution
URI 1050 solution in Java language / URI 1050 code in java:
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"); } } }
URI 1050 solution in C++ language / URI 1050 code in C++:
#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; }
URI 1050 solution in Python language / URI 1050 code in Python language:
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"
Tags: URI Online Judge Solution, URI OJ Solution list, URI Problems Solution, URI solver, URI all problem solution list, URI 1050 DDD code in C, URI 1050 code in C++, URI 1050 DDD solution in C, URI solution, URI 1050 Animal solution in C, URI 1050 solution in C++-CPP,URI 1050 solution in C# (C sharp),URI 1050 solution in Java,URI 1050 DDD solution in Python,
URI DDD problem solution, URI 1050 problem solution
No comments:
Post a Comment