Advertisement
finySTAR

Untitled

May 2nd, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.60 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 gyak_konnyu
  8. {
  9.     class Prima
  10.     {
  11.         private int _Generalt_szam;
  12.         public Prima(int z)
  13.         {
  14.             this._Generalt_szam=Generalt_szam;
  15.         }
  16.         public void Prime_e(int a)
  17.         {
  18.             int primek = 0;
  19.             for (int i = 0; i < 101; i++)
  20.             {
  21.                 if (a % i == 0)
  22.                 {
  23.                     primek++;
  24.                     Console.WriteLine("A szám prím");
  25.                 }
  26.                 else
  27.                 {
  28.                     Console.WriteLine("A szám nem prím");
  29.                 }
  30.             }
  31.             Console.WriteLine("Osztok száma:{0}",primek);
  32.         }
  33.         public int Generalt_szam
  34.         {
  35.             get
  36.             {
  37.                 return _Generalt_szam;
  38.             }
  39.             set
  40.             {
  41.                 _Generalt_szam = value;
  42.                 if (value%2!=0 || value<100)
  43.                 {
  44.  
  45.                 }
  46.             }
  47.         }
  48.     }
  49.     class Program
  50.     {
  51.         static void Main(string[] args)
  52.         {
  53.             Random rnd = new Random();
  54.             int c = rnd.Next(99);
  55.             for (int i = 0; i < c; i++)
  56.             {
  57.                 if (c % 2 != 0)
  58.                 {
  59.                     Prima b = new Prima(c);
  60.                     b.Prime_e(c);
  61.                     Console.Write("Feladat:{0}",b.Prime_e(c));
  62.                 }
  63.  
  64.             }
  65.            
  66.             Console.ReadLine();
  67.         }
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement