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;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] t = new int[10];
- Random r = new Random();
- int i, osztodb, primdb=0;
- for (i = 0; i < 10; i++)
- {
- t[i] = r.Next(10, 30);
- }
- for (i = 0; i < 10; i++)
- {
- Console.WriteLine(t[i]);
- }
- for(i = 0; i<10; i++)
- {
- osztodb = 0;
- for(int j = 1; j <= t[i]; j++)
- {
- if(t[i] % j == 0)
- {
- osztodb++;
- }
- }
- if(osztodb == 2)
- {
- primdb++;
- }
- }
- Console.WriteLine("A tömbben {0} db prim szám van.", primdb);
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement