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 task2
- {
- class pn
- {
- static public int[] PrimeNumbers(int m, int n)
- {
- int size=0;
- int[] result = new int[size];
- if (m==1) {m=2;}
- if (n==1) {n=2;}
- for (int i = m; i <= n; i++)
- {
- int testprime=0;
- for (int j = 2; j < i; j++)
- {
- if (i % j == 0)
- { testprime++; }
- }
- if (testprime == 0)
- {
- size++;
- Array.Resize<int>(ref result, size);
- result[size - 1] = i;
- }
- }
- int LPN = result.Length;
- return result;
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- int t = Int32.Parse(Console.ReadLine());
- int[][] mn=new int[t][];
- for (int i = 0; i < t; i++)
- {
- string line = Console.ReadLine();
- mn[i] = line.Split(' ').Select(s => { return s == "" ? 0 : Convert.ToInt32(s); }).ToArray();
- }
- for (int i = 0; i < t; i++)
- {
- if (mn[i][0]==1 && mn[i][1]==1)
- {
- Console.WriteLine("");
- break;
- }
- int lenght=pn.PrimeNumbers(mn[i][0], mn[i][1]).Length;
- int[] PNresult=new int[lenght];
- Array.Copy(pn.PrimeNumbers(mn[i][0], mn[i][1]), PNresult, lenght);
- for (int j = 0; j < lenght;j++)
- {
- Console.WriteLine("{0}", PNresult[j]);
- }
- Console.WriteLine("");
- }
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement