result:=i;
end;
procedure Vipolnit;//Π·Π°ΠΏΠΎΠ»Π½ΡΠ΅ΠΌ ΠΌΠ°ΡΡΠΈΠ²Ρ.
var.
Ia, m: integer;
begin.
randomize;
Form1.ListBox1.clear;
for Ia:=1 to 25 do begin.
a[Ia]: =random (100);
Form1.ListBox1.items.add (inttostr (a[Ia]));
end;
end;
procedure Prosmotr;//ΠΏΡΠΎΡΠΌΠΎΡΡ
var.
Ia, m: integer;
begin.
m:=a[MaxI];
Ia:=a[MinI];
a[MinI]: =m;
a[MaxI]: =Ia;
showmessage ('a[MinI]='+inttostr (a[MinI])+', a[MaxI]='+inttostr (a[MaxI]));
Form1.ListBox1.clear;
for Ia:=1 to 25 do.
Form1.ListBox1.items.add (inttostr (a[Ia]));
end;
procedure TForm1. Button1Click (Sender: TObject);
begin.
Vipolnit;
end;
procedure TForm1. Button2Click (Sender: TObject);
begin.
Prosmotr;
end;
end.
4.
ΠΠΎΠ΄ΠΈΡΠΎΠ²ΡΠΈΠΊ. ΠΠ°ΠΏΠΈΡΠ°ΡΡ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ, ΠΏΠ΅ΡΠ΅ΠΊΠΎΠ΄ΠΈΡΡΡΡΡΡ ΡΡΡΠΎΠΊΡ Π² ΠΊΠΎΠ΄ΠΈΡΠΎΠ²ΠΊΠ΅ KOI Π² ΡΡΡΠΎΠΊΡ Π² ΠΊΠΎΠ΄ΠΈΡΠΎΠ²ΠΊΠ΅ Windows-1251 ΠΈ ΠΎΠ±ΡΠ°ΡΠ½ΠΎ.
ΠΠΈΡΡΠΈΠ½Π³ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ:
using System;
using System.Collections.Generic;
using System. Linq;
using System. Text;
using System.Threading.Tasks;
namespace ConsoleApplication2.
{.
class ConvertExampleClass.
{.
static void Main ().
{.
string unicodeString = «Π― Π³Π°Π½Π°ΡΡΡΡ, ΡΡΠΎ ΠΆΡΠ²Ρ Ρ ΠΠ΅Π»Π°ΡΡΡΠΈ!» ;
Encoding ascii = Encoding. ASCII;
Encoding unicode = Encoding. Unicode;
byte[] unicodeBytes = unicode. GetBytes (unicodeString);
byte[] asciiBytes = Encoding. Convert (unicode, ascii, unicodeBytes);
char[] asciiChars = new char[ascii.GetCharCount (asciiBytes, 0, asciiBytes. Length)];
ascii.GetChars (asciiBytes, 0, asciiBytes. Length, asciiChars, 0);
string asciiString = new string (asciiChars);
// Display the strings created before and after the conversion.
Console.WriteLine («ΠΡΠΈΠ³ΠΈΠ½Π°Π»ΡΠ½Π°Ρ ΡΡΡΠΎΠΊΠ°: {0}», unicodeString);
Console.WriteLine («Ascii ΡΡΡΠΎΠΊΠ°: {0}», asciiString);
System.Threading.Thread.Sleep (10 000);
}.
}.
}.
ΠΠ°Π΄Π°Π½ΠΈΠ΅ 5. ΠΊΠΎΠΌΠΏΡΡΡΠ΅Ρ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΠΈΡΠΎΠ²Π°Π½ΠΈΠ΅ ΠΈΠ½ΡΠ΅ΡΡΠ΅ΠΉΡ ΡΠ°Π±Π»ΠΈΡΠ½ΡΠΉ Π‘ΡΠΌΠΌΠ° Π΄Π²ΡΡ
ΠΏΠ΅ΡΠ²ΡΡ
ΡΠΈΡΡ Π·Π°Π΄Π°Π½Π½ΠΎΠ³ΠΎ ΡΠ΅ΡΡΡΠ΅Ρ
Π·Π½Π°ΡΠ½ΠΎΠ³ΠΎ ΡΠΈΡΠ»Π° ΡΠ°Π²Π½Π° ΡΡΠΌΠΌΠ΅ Π΄Π²ΡΡ
Π΅Π³ΠΎ ΠΏΠΎΡΠ»Π΅Π΄Π½ΠΈΡ
ΡΠΈΡΡ.
ΠΠΈΡΡΠΈΠ½Π³ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ:
using System;
using System.Collections.Generic;
using System. Linq;
using System. Text;
using System.Threading.Tasks;
namespace ConsoleApplication2.
{.
class Program.
{.
static void Main (string[] args).
{.
int x = int. Parse (Console.ReadLine ());
if (x 9999) Console. WriteLine («Π§ΠΈΡΠ»ΠΎ Π½Π΅ ΡΠ΅ΡΡΡΠ΅Ρ
Π·Π½Π°ΡΠ½ΠΎΠ΅»);
else if ((x / 1000) + ((x / 100) % 10) == ((x / 10) % 10) + (x % 10)) Console. WriteLine («Π Π°Π²Π½ΠΎ»);
else Console. WriteLine («ΠΠ΅ ΡΠ°Π²Π½ΠΎ»);
System.Threading.Thread.Sleep (100 000);
}.
}.
}.
ΠΠ°Π΄Π°Π½ΠΈΠ΅ 6.
Π Π°Π·ΡΠ°Π±ΠΎΡΠ°ΡΡ ΠΠ SQL ΡΠΎ ΡΠ»Π΅Π΄ΡΡΡΠΈΠΌΠΈ ΡΡΡΠ½ΠΎΡΡΡΠΌΠΈ: ΡΡΡΠ°Π½Π°, Π³ΠΎΡΠΎΠ΄, ΠΎΠ±Π»Π°ΡΡΡ, ΠΊΡΠ°ΠΉ.
ΠΠΈΡΡΠΈΠ½Π³ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ:
using System;
using System.Collections.Generic;
using System. ComponentModel;
using System. Data;
using System.Data.OleDb;
using System. Drawing;
using System. Linq;
using System. Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DB_______________________________________.
{.
public partial class Form1: Form.
{.
public Form1().
{.
InitializeComponent ();
}.
private void Form1_Load (object sender, EventArgs e).
{.
// TODO: Π΄Π°Π½Π½Π°Ρ ΡΡΡΠΎΠΊΠ° ΠΊΠΎΠ΄Π° ΠΏΠΎΠ·Π²ΠΎΠ»ΡΠ΅Ρ Π·Π°Π³ΡΡΠ·ΠΈΡΡ Π΄Π°Π½Π½ΡΠ΅ Π² ΡΠ°Π±Π»ΠΈΡΡ «_1DataSet.strana». ΠΡΠΈ Π½Π΅ΠΎΠ±Ρ
ΠΎΠ΄ΠΈΠΌΠΎΡΡΠΈ ΠΎΠ½Π° ΠΌΠΎΠΆΠ΅Ρ Π±ΡΡΡ ΠΏΠ΅ΡΠ΅ΠΌΠ΅ΡΠ΅Π½Π° ΠΈΠ»ΠΈ ΡΠ΄Π°Π»Π΅Π½Π°.
this.stranaTableAdapter.Fill (this._1DataSet.strana);
// TODO: Π΄Π°Π½Π½Π°Ρ ΡΡΡΠΎΠΊΠ° ΠΊΠΎΠ΄Π° ΠΏΠΎΠ·Π²ΠΎΠ»ΡΠ΅Ρ Π·Π°Π³ΡΡΠ·ΠΈΡΡ Π΄Π°Π½Π½ΡΠ΅ Π² ΡΠ°Π±Π»ΠΈΡΡ «_1DataSet.obl». ΠΡΠΈ Π½Π΅ΠΎΠ±Ρ
ΠΎΠ΄ΠΈΠΌΠΎΡΡΠΈ ΠΎΠ½Π° ΠΌΠΎΠΆΠ΅Ρ Π±ΡΡΡ ΠΏΠ΅ΡΠ΅ΠΌΠ΅ΡΠ΅Π½Π° ΠΈΠ»ΠΈ ΡΠ΄Π°Π»Π΅Π½Π°.
this.oblTableAdapter.Fill (this._1DataSet.obl);
// TODO: Π΄Π°Π½Π½Π°Ρ ΡΡΡΠΎΠΊΠ° ΠΊΠΎΠ΄Π° ΠΏΠΎΠ·Π²ΠΎΠ»ΡΠ΅Ρ Π·Π°Π³ΡΡΠ·ΠΈΡΡ Π΄Π°Π½Π½ΡΠ΅ Π² ΡΠ°Π±Π»ΠΈΡΡ «_1DataSet.city». ΠΡΠΈ Π½Π΅ΠΎΠ±Ρ
ΠΎΠ΄ΠΈΠΌΠΎΡΡΠΈ ΠΎΠ½Π° ΠΌΠΎΠΆΠ΅Ρ Π±ΡΡΡ ΠΏΠ΅ΡΠ΅ΠΌΠ΅ΡΠ΅Π½Π° ΠΈΠ»ΠΈ ΡΠ΄Π°Π»Π΅Π½Π°.
this.cityTableAdapter.Fill (this._1DataSet.city);
_1DataSet d = new _1DataSet ();
for (int i = 0; i < d.Tables.Count; i++).
listBox1.Items.Add (d.Tables[i]. TableName);
}.
private void listBox1_DoubleClick (object sender, EventArgs e).
{.
switch (listBox1.SelectedIndex).
{.
case 0:
bindingNavigator1.BindingSource = cityBindingSource;
dataGridView1.DataSource = cityBindingSource;
break;
case 1:
bindingNavigator1.BindingSource = oblBindingSource;
dataGridView1.DataSource = oblBindingSource;
break;
case 2:
bindingNavigator1.BindingSource = stranaBindingSource;
dataGridView1.DataSource = stranaBindingSource;
break;
}.
}.
ΠΠ°Π΄Π°Π½ΠΈΠ΅ 7.
Π‘ΠΎΠ·Π΄Π°ΡΡ XML ΡΠΏΡΠ°Π²ΠΎΡΠ½ΠΈΠΊ ΠΊΠΎΠΌΠΏΡΡΡΠ΅ΡΠΎΠ². Π‘ΡΡΡΠΊΡΡΡΡ XML-Π΄ΠΎΠΊΡΠΌΠ΅Π½ΡΠ° ΠΏΡΠΎΠ΄ΡΠΌΠ°ΡΡ ΡΠ°ΠΌΠΎΡΡΠΎΡΡΠ΅Π»ΡΠ½ΠΎ. Π Π°ΡΡΠΈΡΠΈΡΡ ΠΊΠ»Π°ΡΡ Computer ΡΡΠ΅Π΄ΡΡΠ²Π°ΠΌΠΈ ΡΠ°Π±ΠΎΡΡ Ρ XML-Π΄ΠΎΠΊΡΠΌΠ΅Π½ΡΠ°ΠΌΠΈ. Π‘ΠΎΠ·Π΄Π°ΡΡ ΠΊΠΎΠ½ΡΡΡΡΠΊΡΠΎΡ Π½Π° ΠΎΡΠ½ΠΎΠ²Π΅ XML-ΡΠ΅Π³Π° (ΠΊΠΎΠ½ΡΡΡΡΠΊΡΠΎΡ ΠΏΡΠΈΠ½7ΠΈΠΌΠ°Π΅Ρ ΠΎΠ±ΡΠ΅ΠΊΡ ΠΊΠ»Π°ΡΡΠ° XmlNode). Π Π°Π·ΡΠ°Π±ΠΎΡΠ°ΡΡ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ ΡΡΠ΅Π½ΠΈΡ ΠΊΠΎΠΌΠΏΡΡΡΠ΅ΡΠΎΠ² ΠΈΠ· ΡΠΏΡΠ°Π²ΠΎΡΠ½ΠΈΠΊΠ° Π² ΠΊΠΎΠ»Π»Π΅ΠΊΡΠΈΡ ArrayList. ΠΠΎΠ±Π°Π²ΠΈΡΡ Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡΡ Π·Π°ΠΏΠΈΡΠΈ ΠΊΠΎΠΌΠΏΡΡΡΠ΅ΡΠΎΠ² Π² ΡΠΏΡΠ°Π²ΠΎΡΠ½ΠΈΠΊ ΠΏΡΡΠ΅ΠΌ Π΄ΠΎΠ±Π°Π²Π»Π΅Π½ΠΈΡ Π½ΠΎΠ²ΠΎΠ³ΠΎ ΡΠ΅Π³Π°.
ΠΠΈΡΡΠΈΠ½Π³ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ:
using System;
using System.Collections.Generic;
using System. Linq;
using System. Text;
using System.Threading.Tasks;
using System. Xml;
using System. Collections;
namespace xml.
{.
class Program.
{.
static void Main (string[] args).
{.
XmlDocument xml = new XmlDocument ();
xml.Load («…Computers.xml»);
XmlNodeList items = xml. GetElementsByTagName («Item»);
// int m=666;
string g="11″ ;
while (Convert.ToString (g) ≠ «0»).
{.
Console.Clear ();
Console.WriteLine («1) ΠΠΎΠΊΠ°Π·Π°ΡΡ Π·Π°ΠΏΠΈΡΠΈ.»);
Console.WriteLine («2) ΠΠΎΠ±Π°Π²ΠΈΡΡ Π·Π°ΠΏΠΈΡΡ.»);
Console.WriteLine («3) ΠΠΎΠ±Π°Π²ΠΈΡΡ Π² ΡΠΏΠΈΡΠΎΠΊ ArrayList.»);
Console.WriteLine («0) ΠΡΡ
ΠΎΠ΄.»);
g = Convert. ToString (Console.ReadLine ());
switch (Convert.ToString (g)).
{.
case «1» :
Console.Clear ();
foreach (XmlNode x in items).
{.
Console.WriteLine («Item {0} = {1}», x. Attributes[0]. Name, x. Attributes[0]. Value);
foreach (XmlNode z in x. ChildNodes).
Console.WriteLine («{0,-10}: {1,-10}», z.Name, z. InnerText);
Console.WriteLine (««);
}.
Console.ReadKey ();
break;
case «2» :
Console.Clear ();
XmlNodeList itemss = xml. GetElementsByTagName («Item»);
XmlElement newItem = xml. CreateElement («Item»);
XmlAttribute at = xml. CreateAttribute («id»);
at.Value = Convert. ToString (itemss.Count + 1);
newItem.SetAttributeNode (at);
XmlElement el;
foreach (XmlNode x in itemss[0]. ChildNodes).
{.
el = xml. CreateElement (x.Name);
Console.Write («{0}: «, x.Name);
string name = Console. ReadLine ();
el.InnerText = name;
newItem.AppendChild (el);
}.
xml.DocumentElement.InsertAfter (newItem, xml.DocumentElement.LastChild);
xml.Save («…Computers.xml»);
break;
case «3» :
ArrayList list = new ArrayList ();
XmlNodeList listN = xml. GetElementsByTagName («Item»);
for (int i = 0; i < listN. Count; i++).
list.Add (listN[i]);
Console.Clear ();
Console.WriteLine («ΠΠΎΠ±Π°Π²Π»Π΅Π½ΠΎ!»);
Console.ReadKey ();
break;
}.
}.
}.
}.
}.
ΠΠ°Π΄Π°Π½ΠΈΠ΅ 8.
Π Π°Π·ΡΠ°Π±ΠΎΡΠ°ΡΡ ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΠ΅ ΡΠΈΡΠΎΠ²Π°Π½ΠΈΡ ΠΈ ΡΠΏΡΠ°Π²Π»Π΅Π½ΠΈΡ ΡΠ°Π·Π»ΠΈΡΠ½ΡΠΌΠΈ Π³Π΅ΠΎΠΌΠ΅ΡΡΠΈΡΠ΅ΡΠΊΠΈΠΌΠΈ ΡΠΈΠ³ΡΡΠ°ΠΌΠΈ.
ΠΠΈΡΡΠΈΠ½Π³ ΠΏΡΠΎΠ³ΡΠ°ΠΌΠΌΡ:
using System;
using System.Collections.Generic;
using System. ComponentModel;
using System. Data;
using System. Drawing;
using System. Linq;
using System. Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace gdi.
{.
public partial class Form1: Form.
{.
private Circle f1;
private Square f2;
private bool stats;
private float sclare;
private float shagSetki;
private Figure f;
private Pen pen;
private PointF cen;
private Color tekColor;// =Color.Red;
Graphics g;
public Form1().
{.
InitializeComponent ();
stats = true;
sclare = (float)1;
shagSetki = 25;
tekColor = Color. Red;
pen = new Pen (tekColor);
this.toolStripLabel4.Text = «X» + Convert. ToString (this.sclare);
}.
private void toolStripButton1_Click (object sender, EventArgs e).
{.
cen = new PointF ();
cen.X = Convert. ToInt32(toolStripTextBox1.Text);
cen.Y = Convert. ToInt32(toolStripTextBox2.Text);
pen = new Pen (tekColor, 3);
if (tabControl1.SelectedIndex == 0).
{.
g = this. tabPage1.CreateGraphics ();
f = new Circle (cen, Convert. ToInt32(toolStripTextBox3.Text), pen, sclare);
}.
else.
{.
g = this. tabPage2.CreateGraphics ();
f = new Square (cen, Convert. ToInt32(toolStripTextBox3.Text), pen, sclare);
}.
tabControl1.Invalidate ();
}.
private void tabPage1_Paint (object sender, PaintEventArgs e).
{.
if (stats).
{.
Pen ww = new Pen (Color.Blue, 1);
PointF p1 =new Point ();
PointF p2 =new Point ();
p1.X=0;
p2.X=tabPage1.Size.Width;
for (float i = tabPage1.Size.Height / 2; i < tabPage1.Size.Height; i += shagSetki * this. sclare)//y.
{.
p1.Y = p2. Y = i;
e.Graphics.DrawLine (ww, p1, p2);
}.
for (float i = tabPage1.Size.Height / 2; i > 0; i -= shagSetki * this. sclare)//y.
{.
p1.Y = p2. Y = i;
e.Graphics.DrawLine (ww, p1, p2);
}.
p1.Y = 0;
p2.Y = tabPage1.Size.Height;
for (float i = tabPage1.Size.Width / 2; i < tabPage1.Size.Width; i += shagSetki * this. sclare)//y.
{.
p1.X = p2. X = i;
e.Graphics.DrawLine (ww, p1, p2);
}.
for (float i = tabPage1.Size.Width / 2; i > 0; i -= shagSetki * this. sclare)//y.
{.
p1.X = p2. X = i;
e.Graphics.DrawLine (ww, p1, p2);
}.
ww.Width = 2;
p1.X = p2. X = tabPage1.Size.Width/2;
p1.Y=0;
p2.Y=tabPage1.Size.Height;
e.Graphics.DrawLine (ww, p1, p2);
p1.Y = p2. Y = tabPage1.Size.Height / 2;
p1.X = 0;
p2.X = tabPage1.Size.Width;
e.Graphics.DrawLine (ww, p1, p2);
}.
if (f ≠ null) f. Draw (g, this. tabPage1. Size);
}.
private void toolStripButton2_Click (object sender, EventArgs e).
{.
stats = !stats;
tabControl1.Invalidate ();
if (stats) toolStripButton2. CheckState = CheckState. Checked;
else toolStripButton2. CheckState = CheckState. Unchecked;
}.
private void tabPage2_Paint (object sender, PaintEventArgs e).
{.
if (stats).
{.
Pen ww = new Pen (Color.Blue, 1);
PointF p1 = new Point ();
PointF p2 = new Point ();
p1.X = 0;
p2.X = tabPage2.Size.Width;
for (float i = tabPage2.Size.Height / 2; i < tabPage2.Size.Height; i += shagSetki * this. sclare)//y.
{.
p1.Y = p2. Y = i;
e.Graphics.DrawLine (ww, p1, p2);
}.
for (float i = tabPage2.Size.Height / 2; i > 0; i -= shagSetki * this. sclare)//y.
{.
p1.Y = p2. Y = i;
e.Graphics.DrawLine (ww, p1, p2);
}.
p1.Y = 0;
p2.Y = tabPage2.Size.Height;
for (float i = tabPage2.Size.Width / 2; i < tabPage2.Size.Width; i += shagSetki * this. sclare)//y.
{.
p1.X = p2. X = i;
e.Graphics.DrawLine (ww, p1, p2);
}.
for (float i = tabPage2.Size.Width / 2; i > 0; i -= shagSetki * this. sclare)//y.
{.
p1.X = p2. X = i;
e.Graphics.DrawLine (ww, p1, p2);
}.
ww.Width = 2;
p1.X = p2. X = tabPage2.Size.Width / 2;
p1.Y = 0;
p2.Y = tabPage2.Size.Height;
e.Graphics.DrawLine (ww, p1, p2);
p1.Y = p2. Y = tabPage2.Size.Height / 2;
p1.X = 0;
p2.X = tabPage2.Size.Width;
e.Graphics.DrawLine (ww, p1, p2);
}.
if (f ≠ null) f. Draw (g, this. tabPage2. Size);
}.
private void toolStripButton5_Click (object sender, EventArgs e).
{.
if (f ≠ null).
{.
f.Move ((float)Convert.ToDouble (this.toolStripTextBox4.Text), this. sclare, Direction. Down);
f.Draw (g, this. tabPage1. Size);
tabControl1.Invalidate ();
}.
}.
private void toolStripButton6_Click (object sender, EventArgs e).
{.
if (f ≠ null).
{.
f.Move ((float)Convert.ToDouble (this.toolStripTextBox4.Text), this. sclare, Direction. Up);
f.Draw (g, this. tabPage1. Size);
tabControl1.Invalidate ();
}.
}.
private void toolStripButton7_Click (object sender, EventArgs e).
{.
if (f ≠ null).
{.
f.Move ((float)Convert.ToDouble (this.toolStripTextBox4.Text), this. sclare, Direction. Left);
f.Draw (g, this. tabPage1. Size);
tabControl1.Invalidate ();
}.
}.
private void toolStripButton8_Click (object sender, EventArgs e).
{.
if (f ≠ null).
{.
f.Move ((float)Convert.ToDouble (this.toolStripTextBox4.Text), this. sclare, Direction. Right);
f.Draw (g, this. tabPage1. Size);
tabControl1.Invalidate ();
}.
}.
private void exitToolStripMenuItem_Click (object sender, EventArgs e).
{.
Application.Exit ();
}.
private void colorToolStripMenuItem_Click (object sender, EventArgs e).
{.
colorDialog1.ShowDialog ();
tekColor = pen. Color = this. colorDialog1.Color;
tabControl1.Invalidate ();
}.
private void toolStripButton3_Click (object sender, EventArgs e).
{.
this.sclare *= 2;
this.toolStripLabel4.Text = «X» + Convert. ToString (this.sclare);
if (f ≠ null) f. Reduce ();
tabControl1.Invalidate ();
}.
private void toolStripButton4_Click (object sender, EventArgs e).
{.
this.sclare /= 2;
this.toolStripLabel4.Text = «X» + Convert. ToString (this.sclare);
if (f ≠ null) f. Increase ();
tabControl1.Invalidate ();
}.
private void tabPage2_MouseDoubleClick (object sender, MouseEventArgs e).
{.
Point p = new Point (e.X, e. Y);
if (f ≠ null) if (f.CheckHit (p)) MessageBox. Show («ΠΠΎΠΏΠ°Π»!»);
}.
private void tabPage1_MouseDoubleClick (object sender, MouseEventArgs e).
{.
Point p = new Point (e.X, e. Y);
if (f ≠ null) if (f.CheckHit (p)) MessageBox. Show («ΠΠΎΠΏΠ°Π»!»);
}.
private void tabControl1_SelectedIndexChanged (object sender, EventArgs e).
{.
this.sclare = 1;
this.toolStripLabel4.Text = «X» + Convert. ToString (this.sclare);
}.
}.
}.