Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Напишете програма която приема вход от клавиатурата цяло число n >= 2
- * и отпечатва на екрана всички възможни двойки числа в интервала [1..n] .
- * Двойките N M и M N се считат за еднакви,
- * затова да се отпечата само една от двете.
- Например за n = 3 изхода ще е:
- 1 2
- 1 3
- 2 3 */
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _3.EX
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.Write("Enter the numbers count: ");
- int numberCount = int.Parse(Console.ReadLine());
- int[] numberArray = new int[numberCount];
- for (int i = 0; i < numberCount; i++)
- {
- numberArray[i] = int.Parse(Console.ReadLine());
- }
- // Solution using loop and if statement
- int minimum = numberArray[0];
- int maximum = numberArray[0];
- for (int i = 0; i < numberArray.Length; i++)
- {
- if (maximum < numberArray[i])
- {
- maximum = numberArray[i];
- }
- if (minimum > numberArray[i])
- {
- minimum = numberArray[i];
- }
- }
- Console.WriteLine("Mnimum = {0}",minimum);
- Console.WriteLine("Maximum = {0}",maximum);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment