Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Глава 6, 7, 8.docx
Скачиваний:
0
Добавлен:
12.01.2020
Размер:
591.45 Кб
Скачать

Глава VIII

Файлы

Ивин П.А.

ЭИС-14

Вариант 6

Задание: Код программы: private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)

{

srand(time(0));

ofstream fX;

fX.open("FileX.txt");

ofstream fY;

fY.open("FileY.txt");

ifstream fin1;

fin1.open("FileY.txt");

ifstream fin;

fin.open("FileX.txt");

if (!fin.is_open())

MessageBox::Show("Ошибка считывания файла");

double x, y;

unsigned char i, n;

n = rand() % 91 + 10;

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

{

x = 200 * rand() - 100;

fX << x << endl;

}

while (!fin.eof())

{

fin >> x;

y = (pow(x, 2) + 1) / (pow(x, 3) + 2);

fY << x << " " << y << endl;

}

if (!fX.is_open())

MessageBox::Show("Ошибка открытия файла");

fin.close();

fin1.close();

fX.close();

fY.close();

Process::Start("notepad.exe", "FileY");

}

Глава IX

Записи

Ивин П.А.

ЭИС-14

Вариант 6

Задание: Составить программу, выводящую на экран список книг домашней библиотеки (автор,

название книги, издательство, год издания, стоимость). Распечатать список книг

заданного автора.

Код программы:

#pragma endregion

void SK()

{

ofstream st;

st.open("Steve.txt");

st << "Буря столетия" << endl;

st << "Томминокеры" << endl;

st << "11/22/63" << endl;

st.close();

Process::Start("notepad.exe", "Steve");

}

void MB()

{

ofstream mb;

mb.open("Michail.txt");

mb << "Собачье сердце" << endl;

mb << "Белая гвардия" << endl;

mb << "Собачье сердце" << endl;

mb.close();

Process::Start("notepad.exe", "Michail");

}

void LT()

{

ofstream lt;

lt.open("Lev.txt");

lt << "Учение Христа, изложенное для детей" << endl;

lt << "Анна Каренина" << endl;

lt << "Хаджи-Мурат" << endl;

lt.close();

Process::Start("notepad.exe", "Lev");

}

void IB()

{

ofstream ib;

ib.open("Ivan.txt");

ib << "Молодость и старость" << endl;

ib << "Тень птицы" << endl;

ib << "Темные аллеи" << endl;

ib.close();

Process::Start("notepad.exe", "Ivan");

}

void AC()

{

ofstream ac;

ac.open("Anton.txt");

ac << "Толстый и тонкий" << endl;

ac << "Три сестры" << endl;

ac << "Каштанка" << endl;

ac.close();

Process::Start("notepad.exe", "Anton");

}

private: System::Void dataGridView1_CellContentClick(System::Object^ sender, System::Windows::Forms::DataGridViewCellEventArgs^ e)

{

dataGridView1->Rows[0]->Cells[0]->Value = "1";

}

private: System::Void Zapisi_Load(System::Object^ sender, System::EventArgs^ e)

{

for (int i = 0; i < 14; i++)

{

dataGridView1->Rows->Add();

dataGridView1->Rows[i]->HeaderCell->Value = Convert::ToString(i + 1);

}

dataGridView1->Rows[0]->Cells[0]->Value = "Стивен Кинг ";

dataGridView1->Rows[0]->Cells[1]->Value = "Буря столетия";

dataGridView1->Rows[1]->Cells[1]->Value = "Томминокеры";

dataGridView1->Rows[2]->Cells[1]->Value = "11/22/63";

dataGridView1->Rows[3]->Cells[1]->Value = "Мастер и Маргарита";

dataGridView1->Rows[4]->Cells[1]->Value = "Белая гвардия";

dataGridView1->Rows[5]->Cells[1]->Value = "Собачье сердце";

dataGridView1->Rows[6]->Cells[1]->Value = "Учение Христа";

dataGridView1->Rows[7]->Cells[1]->Value = "Анна Каренина";

dataGridView1->Rows[8]->Cells[1]->Value = "Хаджи-Мурат";

dataGridView1->Rows[9]->Cells[1]->Value = "Молодость и старость";

dataGridView1->Rows[10]->Cells[1]->Value = "Тень птицы";

dataGridView1->Rows[11]->Cells[1]->Value = "Темные аллеи";

dataGridView1->Rows[12]->Cells[1]->Value = "Толстый и тонкий";

dataGridView1->Rows[13]->Cells[1]->Value = "Три сестры";

dataGridView1->Rows[14]->Cells[1]->Value = "Каштанка";

for (int i = 0; i < 4; i++)

dataGridView1->Rows[i]->Cells[2]->Value = "АСТ";

dataGridView1->Rows[4]->Cells[2]->Value = "Мартин";

dataGridView1->Rows[5]->Cells[2]->Value = "Ладомир";

dataGridView1->Rows[6]->Cells[2]->Value = "Свет";

dataGridView1->Rows[7]->Cells[2]->Value = "АСТ";

dataGridView1->Rows[8]->Cells[2]->Value = "Мартин";

dataGridView1->Rows[9]->Cells[2]->Value = "Т8 RUGRAM";

dataGridView1->Rows[10]->Cells[2]->Value = "Т8 RUGRAM";

dataGridView1->Rows[11]->Cells[2]->Value = "Мартин";

dataGridView1->Rows[12]->Cells[2]->Value = "Азбука-Аттикус";

dataGridView1->Rows[13]->Cells[2]->Value = "Златоуст";

dataGridView1->Rows[14]->Cells[2]->Value = "Энас";

dataGridView1->Rows[0]->Cells[3]->Value = "2018";

dataGridView1->Rows[1]->Cells[3]->Value = "2017";

dataGridView1->Rows[2]->Cells[3]->Value = "2016";

dataGridView1->Rows[3]->Cells[3]->Value = "2016";

dataGridView1->Rows[4]->Cells[3]->Value = "2019";

dataGridView1->Rows[5]->Cells[3]->Value = "2017";

dataGridView1->Rows[6]->Cells[3]->Value = "2019";

for (int i = 7; i < 11; i++)

dataGridView1->Rows[i]->Cells[3]->Value = "2018";

dataGridView1->Rows[11]->Cells[3]->Value = "2017";

dataGridView1->Rows[12]->Cells[3]->Value = "2018";

dataGridView1->Rows[13]->Cells[3]->Value = "2017";

dataGridView1->Rows[14]->Cells[3]->Value = "2008";

dataGridView1->Rows[0]->Cells[4]->Value = "375р";

dataGridView1->Rows[1]->Cells[4]->Value = "423р";

dataGridView1->Rows[2]->Cells[4]->Value = "411р";

dataGridView1->Rows[3]->Cells[4]->Value = "83р";

dataGridView1->Rows[4]->Cells[4]->Value = "154р";

dataGridView1->Rows[5]->Cells[4]->Value = "230р";

dataGridView1->Rows[6]->Cells[4]->Value = "99р";

dataGridView1->Rows[7]->Cells[4]->Value = "143р";

dataGridView1->Rows[8]->Cells[4]->Value = "146р";

dataGridView1->Rows[9]->Cells[4]->Value = "395р";

dataGridView1->Rows[10]->Cells[4]->Value = "397р";

dataGridView1->Rows[11]->Cells[4]->Value = "100р";

dataGridView1->Rows[12]->Cells[4]->Value = "114р";

dataGridView1->Rows[13]->Cells[4]->Value = "310р";

dataGridView1->Rows[14]->Cells[4]->Value = "160р";

dataGridView1->AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode::AutoSizeToAllHeaders);

dataGridView1->AutoResizeColumns();

}

private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)

{

SK();

}

private: System::Void button2_Click(System::Object^ sender, System::EventArgs^ e) { SK(); }

private: System::Void button3_Click(System::Object^ sender, System::EventArgs^ e) { SK(); }

private: System::Void button4_Click_1(System::Object^ sender, System::EventArgs^ e) {MB();}

private: System::Void button5_Click_1(System::Object^ sender, System::EventArgs^ e) {MB();}

private: System::Void button6_Click(System::Object^ sender, System::EventArgs^ e) {MB();}

private: System::Void button7_Click(System::Object^ sender, System::EventArgs^ e) {LT();}

private: System::Void button8_Click(System::Object^ sender, System::EventArgs^ e) {LT();}

private: System::Void button9_Click(System::Object^ sender, System::EventArgs^ e) {LT();}

private: System::Void button10_Click(System::Object^ sender, System::EventArgs^ e) {IB();}

private: System::Void button11_Click(System::Object^ sender, System::EventArgs^ e) {IB();}

private: System::Void button12_Click(System::Object^ sender, System::EventArgs^ e) {IB();}

private: System::Void button13_Click(System::Object^ sender, System::EventArgs^ e) {AC();}

private: System::Void button14_Click(System::Object^ sender, System::EventArgs^ e) {AC();}

private: System::Void button15_Click(System::Object^ sender, System::EventArgs^ e) {AC();}

Соседние файлы в предмете Информатика