Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Korki
- {
- class Program
- {
- static int minmalValue = 0;
- static int maximalValue = 1000000;
- static int value;
- static void Main(string[] args)
- {
- Console.WriteLine($"Podaj liczbę z zakresu {minmalValue} do {maximalValue}");
- while (true)
- {
- var enter = Console.ReadLine();
- var result = CheckEnter(enter);
- if (result)
- {
- break;
- }
- else {
- Console.WriteLine("Zła liczba podaj nową.");
- }
- }
- var array = GetAllocators(value);
- for (int i = 0; i < array.Length; i++)
- {
- Console.WriteLine(array[i]);
- }
- Console.ReadKey();
- }
- static bool CheckEnter(string enter)
- {
- int result;
- var succeeded = int.TryParse(enter, out result);
- if (succeeded)
- {
- if (result > minmalValue && result < maximalValue)
- {
- value = result;
- return true;
- }
- else
- {
- return false;
- }
- }
- else
- {
- return false;
- }
- }
- static int[] GetAllocators(int value)
- {
- var counter = 0;
- var temp = new int[value];
- for (int i = 1; i <= value; i++)
- {
- var res = value % i;
- if (res == 0)
- {
- temp[counter] = i;
- counter++;
- }
- }
- return temp;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement