OneTallor

kasua

Mar 29th, 2017
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.09 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 ConsoleApplication3
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             // elso feladat
  14.             int[] eszam = new int[20];
  15.             Random rnd = new Random();
  16.  
  17.             for (int i = 0; i < eszam.Length; i++)
  18.             {
  19.                 eszam[i] = rnd.Next(-51, 50);
  20.                 Console.Write("{0,4}", eszam[i]);
  21.             }
  22.          
  23.             // masodik
  24.             bool van = false;
  25.             for (int j = 0; j < eszam.Length; j++)
  26.             {
  27.                 if (eszam[j] % 3 == 0)
  28.                 {
  29.                     van = true;
  30.                 }
  31.             }
  32.             Console.WriteLine(van);
  33.             // harmadik
  34.             int negativ = 0;
  35.             for (int e = 0; e < eszam.Length; e++)
  36.             {
  37.                 if (eszam[e] < 0)
  38.                 {
  39.                     negativ++;
  40.                 }
  41.             }
  42.  
  43.             Console.ReadLine();
  44.         }
  45.     }
  46. }
Add Comment
Please, Sign In to add comment