0% found this document useful (0 votes)
3 views5 pages

Domaci Informatika, Luka Smiljanic 1D

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views5 pages

Domaci Informatika, Luka Smiljanic 1D

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

1. Zadatak.

namespace _1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int x, y;
int x1, y1;
int a, b;
Random R = new Random();
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
Refresh();
x = e.X;
y = e.Y;
}

private void Form1_Load(object sender, EventArgs e)


{

private void Form1_MouseUp(object sender, MouseEventArgs e)


{
x1 = e.X;
y1 = e.Y;
a = Math.Abs(x1 - x);
b = Math.Abs(y1 - y);
x = Math.Min(x1, x);
y = Math.Min(y1, y);
timer1.Start();
}

private void timer1_Tick(object sender, EventArgs e)


{
Graphics g = CreateGraphics();
SolidBrush cetka = new SolidBrush(Color.FromArgb(R.Next(256), R.Next(256),R.Next(256)));
g.FillRectangle(cetka, x, y, a, b);
x += a;
y += b;
a -= 5;
b -= 5;
if(a<=5 || b<=5)
{
timer1.Stop();
}
if(x+a>ClientRectangle.Width || y+b>ClientRectangle.Height)
{
timer1.Stop();
}

}
}
2.Zadatak
namespace _4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
void racunaj(double a, out double obim,out double povrsina,out double visina)
{
obim=a*3;
povrsina=a*a*Math.Sqrt(3)/4;
visina=a*Math.Sqrt(3)/2;
}
void crtajtrougao(Graphics g, int x,int y, double a, double h,Color boja)
{

Pen olovka= new Pen(boja);


g.DrawLine(olovka,x-(int)a/2,y+(int)h*2/3,x+(int)a/2,y+(int)h*2/3);
g.DrawLine(olovka,x-(int)a/2,y+(int)h*2/3,x,y-(int)h*2/3);
g.DrawLine(olovka,x,y-(int)h*2/3,x+(int)a/2,y+(int)h*2/3);
}
Random R = new Random();
int x, y;
double a;
double h;

private void Form1_Load(object sender, EventArgs e)


{

private void pictureBox1_MouseClick(object sender, MouseEventArgs e)


{
Refresh();
a = double.Parse(textBox1.Text);
h = a * Math.Sqrt(3) / 2;
Color boja = Color.FromArgb(R.Next(256), R.Next(256), R.Next(256));
x = e.X;
y = e.Y;
Graphics g = pictureBox1.CreateGraphics();
crtajtrougao(g, x, y, a, h, boja);}
}
}
3.Zadatak
namespace _2
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int x, y;
int x1, y1;
Random R = new Random();
private void Form1_Load(object sender, EventArgs e)
{

private void Form1_MouseDown(object sender, MouseEventArgs e)


{
Refresh();
x = e.X;
y = e.Y;
timer1.Start();
}

private void Form1_MouseUp(object sender, MouseEventArgs e)


{
timer1.Stop();
}
private void timer1_Tick(object sender, EventArgs e)
{
Graphics g = CreateGraphics();
Pen olovka = new Pen(Color.Blue);
y1 = R.Next(0, ClientRectangle.Height);
x1 = ClientRectangle.Width;
g.DrawLine(olovka, x, y, x1, y1);
g.DrawLine(olovka, x, y, 0, y1);
y1 = R.Next(0, ClientRectangle.Height);
}
}
}
4.Zadatak
namespace _6
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
char rang(int brojPoena)
{
if (brojPoena >= 85) return 'A';
if (65 <= brojPoena) return 'B';
if (45 <= brojPoena) return 'C';
return 'D';

}
private void Form1_Load(object sender, EventArgs e)
{

}
int max = 0, br = 0, min = int.MaxValue;
float ukbodovi = 0;
char rang;
private void button1_Click(object sender, EventArgs e)
{
string s = textBox1.Text;
int p = s.IndexOf(' ');
string ime, prezime;
int bodovi;
ime = s.Substring(0, p);
s = s.Substring(p + 1);
p = s.IndexOf(' ');
prezime = s.Substring(0, p);
s = s.Substring(p + 1);
bodovi = int.Parse(s);
listBox1.Items.Add(ime.Substring(0, 1) + "." + prezime + " " + rang);
br++;
ukbodovi += bodovi;
max = Math.Max(max, bodovi);
min = Math.Min(min, bodovi);
label1.Text = "maksimalno je" + max;
label2.Text = "minimalno je" + min;
label3.Text = "prosek bodova je" + ukbodovi / br;
}

}
}
5.Zadatak
namespace Idealna_težina
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)


{
int visina = int.Parse(textBox1.Text.Substring(0, textBox1.Text.IndexOf(' ')));
int tezina = int.Parse(textBox1.Text.Substring(textBox1.Text.IndexOf(' ')));
int a;
if (radioButton1.Checked)
{
a = visina - 100;
}
else a = visina - 110;
if (tezina == a) label1.Text = "Vi imate idealnu težinu.";
else
{
if (tezina < a) label1.Text = "Treba da se ugojite " + (a - tezina) + "kg.";
else label1.Text = label1.Text = "Treba da smršate " + (tezina - a) + "kg.";
}
}
}
}

You might also like