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.Runtime.InteropServices;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication1
- {
- [StructLayout(LayoutKind.Sequential)]
- public struct Point
- {
- public float X { get; set; }
- public float Y { get; set; }
- public Point(float x, float y)
- : this()
- {
- X = x;
- Y = y;
- }
- }
- class Program
- {
- static int[] grid = new int[10000];
- static Point dimenzije = new Point(4, 4);
- static void Main(string[] args)
- {
- Console.Write("Dimenzije: ");
- string ocitano = Console.ReadLine();
- string[] dim = ocitano.Split();
- dimenzije = new Point(Convert.ToInt16(dim[0]), Convert.ToInt16(dim[1]));
- ocitano = Console.ReadLine();
- algoritam();
- drawiksove();
- Console.ReadLine();
- }
- static void drawiksove()
- {
- string ispis = "";
- for (int i = 0; i < dimenzije.X * dimenzije.Y; i++)
- {
- if (i % (int)dimenzije.X == 0)
- {
- //Console.WriteLine(i);
- Console.Write('\n');
- }
- Console.Write(grid[i]);
- }
- Console.Write(ispis);
- }
- static void algoritam()
- {
- Random rand = new Random();
- Point pocetna = new Point(rand.Next((int)dimenzije.X), rand.Next((int)dimenzije.Y));
- for (int i = 0; i < dimenzije.X*dimenzije.Y; i++)
- {
- int broj = rand.Next(100);
- int brojPrepreke = rand.Next(4, 9);
- if (broj < 10)
- {
- grid[i]=brojPrepreke;
- }
- else if (broj < 18) {
- grid[i] = 1;
- }
- }
- int brojStartnePozicije = rand.Next((int)dimenzije.X * (int)dimenzije.Y - 5);
- while (brojStartnePozicije % dimenzije.X > 10)
- {
- brojStartnePozicije = rand.Next((int)dimenzije.X * (int)dimenzije.Y - 5);
- }
- grid[brojStartnePozicije] = 1;
- grid[brojStartnePozicije + 1] = 1;
- grid[brojStartnePozicije + 2] = 1;
- grid[brojStartnePozicije + 3] = 1;
- Console.Write(brojStartnePozicije%15);
- Console.Write("\n");
- Console.Write(brojStartnePozicije / 15);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement