1180 beecrowd URI | Code Ease (2024)

Answered on: Friday 15 March, 2024 / Duration: 14 min read

Programming Language: C# , Popularity :9/10


1180 beecrowd URI | Code Ease (1)

Solution 1:

The 1180 problem on Beecrowd URI is a simple problem that involves finding the smallest number in an array along with its index. Here is the C# code to solve this problem:

c#
using System;
class Program
{
static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
string[] input = Console.ReadLine().Split();

int smallest = int.Parse(input[0]);
int index = 0;

for (int i = 1; i < n; i++)
{
int current = int.Parse(input[i]);
if (current < smallest)
{
smallest = current;
index = i;
}
}

Console.WriteLine("Menor valor: " + smallest);
Console.WriteLine("Posicao: " + index);
}
}

Sample Input:


5
2 4 6 8 1

Sample Output:


Menor valor: 1
Posicao: 4

In this code, we first read the number of elements in the array (n) and then read the array elements as input. We initialize the smallest number as the first element of the array and then iterate through the array to find the smallest number and its index. Finally, we print the smallest number and its index as output.

Solution 2:

Problem Statement (1180 - Lowest Number and Position)

Given an integer array of size N, you need to find the lowest number in the array and its position in the array.

Input

The input consists of several test cases. The first line of each test case contains the integer N (1 ≤ N ≤ 1000). The second line contains N space-separated integers.

Output

For each test case, print two integers on a single line: the lowest number in the array and its position in the array. If there are multiple occurrences of the lowest number, print the position of the first occurrence.

Code Example in C#

csharp
using System;
class Program
{
static void Main(string[] args)
{
int testCases = int.Parse(Console.ReadLine());
for (int i = 0; i < testCases; i++)
{
int n = int.Parse(Console.ReadLine());
int[] arr = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
// Find the lowest number and its position
int lowest = arr[0];
int position = 1;
for (int j = 1; j < n; j++)
{
if (arr[j] < lowest)
{
lowest = arr[j];
position = j + 1;
}
}
// Print the lowest number and its position
Console.WriteLine($"{lowest} {position}");
}
}
}

Input Example:


3
5
1 2 3 4 5
4
10 20 30 40
6
100 200 300 400 500 600

Output Example:


1 1
10 1
100 1

Solution 3:

Problem 1180 from Beecrowd URI (also known as the "URI Online Judge") is a problem related to currency conversion. The problem statement is as follows:

A foreigner wants to know how much, in dollars, a product that costs X reais will cost. Write a program that reads the dollar price and the price of the product in reais and calculates the cost of the product in dollars.

Here's a possible solution in C#:

csharp
using System;
class Program
{
static void Main(string[] args)
{
// Read the price of the dollar and the price of the product in reais
Console.Write("Enter the dollar price: ");
double dollarPrice = Convert.ToDouble(Console.ReadLine());
Console.Write("Enter the product price in reais: ");
double productPriceReais = Convert.ToDouble(Console.ReadLine());
// Calculate the cost of the product in dollars
double productPriceDollars = productPriceReais / dollarPrice;
// Display the result
Console.WriteLine($"The product price in dollars is: {productPriceDollars:F2}");
}
}

In this code, we first read the price of the dollar and the price of the product in reais from the standard input using the Console.ReadLine() method. We then convert the strings to double values using the Convert.ToDouble() method.

Next, we calculate the cost of the product in dollars by dividing the price of the product in reais by the price of the dollar. We use the F2 format specifier in the Console.WriteLine() method to display the result with two decimal places.

Here's an example output of the program:


Enter the dollar price: 5.00
Enter the product price in reais: 100.00
The product price in dollars is: 20.00

In this example, the price of the dollar is R$ 5.00 and the price of the product is R$ 100.00. Therefore, the cost of the product in dollars is US$ 20.00.

More Articles :


C# programatically Add an entry to the AppConfig File

Answered on: Friday 15 March, 2024 / Duration: 5-10 min read

Programming Language : C# , Popularity : 10/10

Read More ...

how to write boolean condition in if statement at c#

Answered on: Friday 15 March, 2024 / Duration: 5-10 min read

Programming Language : C# , Popularity : 4/10

Read More ...

refresh cancel token c#

Answered on: Friday 15 March, 2024 / Duration: 5-10 min read

Programming Language : C# , Popularity : 7/10

Read More ...

JSON.NET Error Self referencing loop

Answered on: Friday 15 March, 2024 / Duration: 5-10 min read

Programming Language : C# , Popularity : 10/10

Read More ...

An expression tree lambda may not contain a null propagating operator.

Answered on: Friday 15 March, 2024 / Duration: 5-10 min read

Programming Language : C# , Popularity : 7/10

Read More ...

animatro set bool unity

Answered on: Friday 15 March, 2024 / Duration: 5-10 min read

Programming Language : C# , Popularity : 5/10

Read More ...

how to get the screen size in Tao.Freeglut

Answered on: Friday 15 March, 2024 / Duration: 5-10 min read

Programming Language : C# , Popularity : 3/10

Read More ...

how to destroy bridges animal crossing

Answered on: Friday 15 March, 2024 / Duration: 5-10 min read

Programming Language : C# , Popularity : 5/10

Read More ...

C# HttpUtility not found / missing C#

Answered on: Friday 15 March, 2024 / Duration: 5-10 min read

Programming Language : C# , Popularity : 3/10

Read More ...

has_filter WordPress

Answered on: Friday 15 March, 2024 / Duration: 5-10 min read

Programming Language : C# , Popularity : 3/10

Read More ...

entity framework dynamic search

Answered on: Friday 15 March, 2024 / Duration: 5-10 min read

Programming Language : C# , Popularity : 7/10

Read More ...

666

Answered on: Friday 15 March, 2024 / Duration: 5-10 min read

Programming Language : C# , Popularity : 10/10

Read More ...

flyt wordpress fra localserver

Answered on: Friday 15 March, 2024 / Duration: 5-10 min read

Programming Language : C# , Popularity : 5/10

Read More ...

c# param.ExStyle equivalent in java

Answered on: Friday 15 March, 2024 / Duration: 5-10 min read

Programming Language : C# , Popularity : 9/10

Read More ...

now convert htis one into async " public List<sp_AccSizeDropDown_Get_Result> AccSizeDropDown() { try { var AccSize = dbEnt.sp_AccSizeDropDown_Get().ToList(); return AccSize; }

Answered on: Friday 15 March, 2024 / Duration: 5-10 min read

Programming Language : C# , Popularity : 10/10

Read More ...

Handling Collisions unity

Answered on: Friday 15 March, 2024 / Duration: 5-10 min read

Programming Language : C# , Popularity : 3/10

Read More ...

shell32.dll c# example

Answered on: Friday 15 March, 2024 / Duration: 5-10 min read

Programming Language : C# , Popularity : 7/10

Read More ...

real world example of sinleton design pattern

Answered on: Friday 15 March, 2024 / Duration: 5-10 min read

Programming Language : C# , Popularity : 7/10

Read More ...

@using System,System.Core

Answered on: Friday 15 March, 2024 / Duration: 5-10 min read

Programming Language : C# , Popularity : 10/10

Read More ...

c# one line if

Answered on: Friday 15 March, 2024 / Duration: 5-10 min read

Programming Language : C# , Popularity : 6/10

Read More ...

c# registrykey is null

Answered on: Friday 15 March, 2024 / Duration: 5-10 min read

Programming Language : C# , Popularity : 5/10

Read More ...

delete record ef linq

Answered on: Friday 15 March, 2024 / Duration: 5-10 min read

Programming Language : C# , Popularity : 3/10

Read More ...

C# Relational Operators

Answered on: Friday 15 March, 2024 / Duration: 5-10 min read

Programming Language : C# , Popularity : 3/10

Read More ...

c# docs copy existing

Answered on: Friday 15 March, 2024 / Duration: 5-10 min read

Programming Language : C# , Popularity : 9/10

Read More ...

What is the best way to lock cache in asp.net?

Answered on: Friday 15 March, 2024 / Duration: 5-10 min read

Programming Language : C# , Popularity : 7/10

Read More ...

visual studio smart indent C#

Answered on: Friday 15 March, 2024 / Duration: 5-10 min read

Programming Language : C# , Popularity : 6/10

Read More ...

error when using Indentitydbcontext

Answered on: Friday 15 March, 2024 / Duration: 5-10 min read

Programming Language : C# , Popularity : 4/10

Read More ...

c# xml reuse docs

Answered on: Friday 15 March, 2024 / Duration: 5-10 min read

Programming Language : C# , Popularity : 5/10

Read More ...

c# get datetime start

Answered on: Friday 15 March, 2024 / Duration: 5-10 min read

Programming Language : C# , Popularity : 6/10

Read More ...

large blank file C#

Answered on: Friday 15 March, 2024 / Duration: 5-10 min read

Programming Language : C# , Popularity : 8/10

Read More ...

clear rows datagridview after the first row c#

Answered on: Friday 15 March, 2024 / Duration: 5-10 min read

Programming Language : C# , Popularity : 10/10

Read More ...

1180 beecrowd URI | Code Ease (2024)

References

Top Articles
Latest Posts
Article information

Author: Merrill Bechtelar CPA

Last Updated:

Views: 5350

Rating: 5 / 5 (70 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Merrill Bechtelar CPA

Birthday: 1996-05-19

Address: Apt. 114 873 White Lodge, Libbyfurt, CA 93006

Phone: +5983010455207

Job: Legacy Representative

Hobby: Blacksmithing, Urban exploration, Sudoku, Slacklining, Creative writing, Community, Letterboxing

Introduction: My name is Merrill Bechtelar CPA, I am a clean, agreeable, glorious, magnificent, witty, enchanting, comfortable person who loves writing and wants to share my knowledge and understanding with you.