Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
4 лабы 1,2,4,5,6,7,9.docx
Скачиваний:
10
Добавлен:
24.09.2019
Размер:
25 Кб
Скачать
☆

If ((File.Exists(b)) && (File.Exists(s)))

{

Console.Write("введите элементы файла\n");

for (i = 0; i < n; i++)

{

a = Convert.ToInt32(Console.ReadLine());

J.Write(a);

}

J.Close();

BinaryReader F = new BinaryReader

(File.Open(B, FileMode.Open));

If (File.Exists(b))

{

for (i = 0; i < 15; i++)

if (i < n)

{

b[i] = F.ReadInt32();

Y.Write(b[i]);

Console.Write("\n" + b[i]);

}

else

{

b[i] = b[i - n];

Y.Write(b[i]);

Console.Write("\n" + b[i]);

}

Y.Close();

F.Close();

return;

}

}

Console.Write("File Not Found");

}

static void Main(string[] args)

{

bonduelle("C:\\a1.dat","C:\\a2.dat");

Console.ReadKey();

}

}

}

7)

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.IO;

namespace R2D2

{

class Program

{

static void zoey(string B, string S)

{

Int32 i, n,a;

Console.Write("Введите количество элементов\nN=");

n = Convert.ToInt32(Console.ReadLine());

if (n <= 0) { Console.Write("error"); return; }

BinaryWriter J = new BinaryWriter

(File.Open(B, FileMode.Create));

BinaryWriter Y = new BinaryWriter

(File.Open(S, FileMode.Create));

If ((File.Exists(b)) && (File.Exists(s)))

{

Console.Write("введите элементы файла\n");

for (i = 0; i < n; i++)

{

a = Convert.ToInt32(Console.ReadLine());

J.Write(a);

}

J.Close();

BinaryReader F = new BinaryReader

(File.Open(B, FileMode.Open));

If (File.Exists(b))

{

for (i = 0; i < n; i++)

{

a = F.ReadInt32();

Y.Write(a);

Console.Write("\n" + a);

if (a > 0)

{

Y.Write(a);

Console.Write("\n" + a);

}

}

Y.Close();

F.Close();

return;

}

}

Console.Write("File Not Found");

}

static void Main(string[] args)

{

zoey("C:\\a1.dat","C:\\a2.dat");

Console.ReadKey();

}

}

}

1)

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO; namespace R2D2 {     class Program     {         static void Chewbacca(string B, string S)         {             Int32 i, j, n, a, k = 1;             Console.Write("Введите количество элементов\n");             n = Convert.ToInt32(Console.ReadLine());             if (n <= 0) { Console.Write("error"); return; }             BinaryWriter J = new BinaryWriter             (File.Open(B, FileMode.Create));             BinaryWriter Ch = new BinaryWriter             (File.Open(S, FileMode.Create));             if ((File.Exists(B))&&(File.Exists(S)))             {                 Console.Write("Введите элементы файла\n");                 for (i = 0; i < n; i++)                 {                     j = Convert.ToInt32(Console.ReadLine());                     J.Write(j);                 }                 J.Close();                 Console.Write("\n");                 BinaryReader F = new BinaryReader                 (File.Open(B, FileMode.Open));                 if(File.Exists(B)) {                 a = F.ReadInt32();                 for (i = 0; i < n - 1; i++)                 {                     j = F.ReadInt32();                     if (j == a)                         k++;                     else                     {                         Ch.Write(k);                         Console.Write(k+" ");                         k = 1;                     }                     a = j;                 }                 Ch.Write(k);                 Console.Write(k+" ");                 Ch.Close();                 return;                 }             }             Console.Write("File Not Found");         }         static void Main(string[] args)         {             Chewbacca("C:\\a1.dat","C:\\a2.dat");             Console.ReadKey();         }     } }

5)

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.IO;

namespace R2D2

{

class Program

{

static void Solo(string B, string S)

{

Int32 i, n; Double a, b, c, d;

Console.Write("Введите количество элементов\nN=");

n = Convert.ToInt32(Console.ReadLine());

if (n <= 2) { Console.Write("error"); return; }

BinaryWriter J = new BinaryWriter

(File.Open(B, FileMode.Create));

BinaryWriter Y = new BinaryWriter

(File.Open(S, FileMode.Create));