Gyakorlat tömb
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication22
{
class Program
{
static void Main(string[] args)
{
int[] a = { 0, 0,0 };
int b;
for (int c = 0; c < 3; c++)
{
b = Convert.ToInt32(Console.ReadLine());
foreach(int x in a)
{
if (x == b)
{
Console.WriteLine("már van ilyen");
}
}
a[c] = b;
}
foreach(int c in a)
{
Console.Write(c+",");
}
Random rnd = new Random();
int s1, s2, s3, s4, s5, s6;
int[] kocka = { 0, 0, 0, 0, 0, 0 };
s1 = 0;
s2 = 0;
s3 = 0;
s4 = 0;
s5 = 0;
s6 = 0;
for (int ism = 0; ism < 1000; ism++)
{
int dobas = rnd.Next(1, 7);
kocka[dobas - 1]++;
Console.WriteLine(dobas);
switch (dobas)
{
case 1:s1++;
break;
case 2:
s2++;
break;
case 3:
s3++;
break;
case 4:
s4++;
break;
case 5:
s5++;
break;
case 6:
s6++;
break;
}
}
Console.WriteLine(s1);
Console.WriteLine(s2);
Console.WriteLine(s3);
Console.WriteLine(s4);
Console.WriteLine(s5);
Console.WriteLine(s6);
foreach(int elem in kocka)
{
Console.WriteLine(elem);
}
Console.ReadKey();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication22
{
class Program
{
static void Main(string[] args)
{
int[] a = { 0, 0,0 };
int b;
for (int c = 0; c < 3; c++)
{
b = Convert.ToInt32(Console.ReadLine());
foreach(int x in a)
{
if (x == b)
{
Console.WriteLine("már van ilyen");
}
}
a[c] = b;
}
foreach(int c in a)
{
Console.Write(c+",");
}
Random rnd = new Random();
int s1, s2, s3, s4, s5, s6;
int[] kocka = { 0, 0, 0, 0, 0, 0 };
s1 = 0;
s2 = 0;
s3 = 0;
s4 = 0;
s5 = 0;
s6 = 0;
for (int ism = 0; ism < 1000; ism++)
{
int dobas = rnd.Next(1, 7);
kocka[dobas - 1]++;
Console.WriteLine(dobas);
switch (dobas)
{
case 1:s1++;
break;
case 2:
s2++;
break;
case 3:
s3++;
break;
case 4:
s4++;
break;
case 5:
s5++;
break;
case 6:
s6++;
break;
}
}
Console.WriteLine(s1);
Console.WriteLine(s2);
Console.WriteLine(s3);
Console.WriteLine(s4);
Console.WriteLine(s5);
Console.WriteLine(s6);
foreach(int elem in kocka)
{
Console.WriteLine(elem);
}
Console.ReadKey();
}
}
}
Nincsenek megjegyzések:
Megjegyzés küldése