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)
- {
- Console.WriteLine("Hey! Lets fill a lotto ticket!!!");
- Loto file = new Loto();
- int[,] ticket = file.GetTicket();
- Console.WriteLine("Click enter to get your ticket");
- Console.ReadLine();
- Console.Clear();
- for (int i = 0; i < ticket.GetLength(0); i++)
- {
- for (int j = 0; j < ticket.GetLength(1); j++)
- {
- Console.Write(ticket[i, j] + " ");
- }
- Console.WriteLine();
- }
- Console.WriteLine("Click any key to find if you won any numbers:");
- Console.ReadKey();
- Console.WriteLine("The winning numbers are: ");
- int[] win = file.GetWinners();
- for (int i = 0;i < win.Length; i++)
- {
- Console.Write(win[i] + " ");
- }
- Console.WriteLine();
- int x = file.DidIwin();
- Console.WriteLine("You guessed " + x + " right numbers (with a doubling with powerful one) ");
- Console.WriteLine("You won " + (x * 100) + "$ - Congratulations!");
- Console.ReadLine();
- }
- }
- }
- ///////////////////
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication1
- {
- class Loto
- {
- private int[,] ticket;
- private int[] winners;
- public Loto()
- {
- this.ticket = new int[12, 7];
- this.winners = new int[7];
- Random R = new Random();
- int j, i;
- for (i = 0; i < winners.Length - 1; i++)
- {
- winners[i] = R.Next(1, 50);
- }
- winners[winners.Length - 1] = R.Next(1, 10);
- for (i = 0; i < ticket.GetLength(0); i++)
- {
- for (j = 0; j < ticket.GetLength(1) - 1; j++)
- {
- ticket[i, j] = R.Next(1, 50);
- }
- ticket[i, j] = R.Next(1, 10);
- }
- }
- public int[,] GetTicket()
- {
- return this.ticket;
- }
- public int[] GetWinners()
- {
- return this.winners;
- }
- public int DidIwin()
- {
- int sum = 0;
- int counter;
- bool powerful = true;
- int i, j, k;
- for (i = 0; i < this.ticket.GetLength(0); i++)
- {
- counter = 0;
- for (j = 0; j < this.ticket.GetLength(1); j++)
- {
- for (k = 0; k < this.winners.Length - 1; k++)
- {
- if (this.winners[k] == this.ticket[i, j])
- {
- counter++;
- }
- }
- if (counter > 2)
- {
- if (this.winners[winners.Length - 1] == this.ticket[i, j])
- {
- counter *= 2;
- }
- sum += counter;
- }
- }
- }
- return sum;
- }
- }
- }
Add Comment
Please, Sign In to add comment