Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.28 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Minimalna_liczba
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Console.WriteLine("Podaj A");
  14.             int A = Convert.ToInt32(Console.ReadLine());
  15.             Console.WriteLine("Podaj K");
  16.             int K = Convert.ToInt32(Console.ReadLine());
  17.             int[] liczby = new int[A];
  18.             Console.WriteLine("Podaj " + A + " liczb");
  19.             for(int i=0;i<A;i++)
  20.             {
  21.                 liczby[i] = Convert.ToInt32(Console.ReadLine());
  22.             }
  23.             Array.Sort(liczby);
  24.             int j = liczby[0]+1;
  25.             for(; ;)
  26.             {
  27.                 if(j%K==0&&j<liczby[liczby.Length-1])
  28.                 {
  29.                     if(!liczby.Contains(j))
  30.                     {
  31.                         Console.WriteLine("Znaleziono:"+j);
  32.                         break;
  33.                     }
  34.                 }
  35.                 else if(j == liczby[liczby.Length - 1])
  36.                 {
  37.                     Console.WriteLine("Nie znaleziono");
  38.                     break;
  39.                 }
  40.                 j++;
  41.             }
  42.             Console.Read();
  43.  
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement