Pietras286

Podzielność

Dec 13th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.86 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 Problem14
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int t = int.Parse(Console.ReadLine());
  14.             for (int i = 0; i < t; i++)
  15.             {
  16.                 string[] tab = Console.ReadLine().Split(' ');
  17.                 Console.WriteLine(Podzielnosc(int.Parse(tab[0]), int.Parse(tab[1]), int.Parse(tab[2])));
  18.             }
  19.         }
  20.  
  21.         private static string Podzielnosc(int n, int x, int y)
  22.         {
  23.             string wynik = "";
  24.             for (int i = 1; i < n; i++)
  25.             {
  26.                 if (i % x == 0 && i % y != 0)
  27.                 {
  28.                     wynik += i + " ";
  29.                 }
  30.             }
  31.             return wynik;
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment