Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Ivanyuk_Zvit.docx
Скачиваний:
9
Добавлен:
12.05.2015
Размер:
1.59 Mб
Скачать

Практична робота 7 Програми для роботи з рядками даних

Завдання 7.1

Написати програму, яка виводить код введеного користувачем сивола. Умова закінчення роботи програми – ввід точки.

#include "stdafx.h"

#include <iostream>

#include <math.h>

#include <conio.h>

#include <stdlib.h>

#include <iomanip>

#include <stdio.h>

#include <time.h>

using namespace std;

void _tmain(int argc, _TCHAR* argv[])

{

char A;

int Key;

do

{

cout << "A= ";

cin >> A;

Key = (char)A;

cout << "Key =" << Key << endl;

system("PAUSE");

system("cls");

} while (A != '.');

}

Завдання 7.2

Написати програму, яка конвертує введене користувачем восьми розрядне двійкове число в десяткове.

#include "stdafx.h"

#include <iostream>

#include <math.h>

#include <conio.h>

#include <stdlib.h>

#include <iomanip>

#include <stdio.h>

#include <time.h>

using namespace std;

void _tmain(int argc, _TCHAR* argv[])

{

char x[10];

long int x1;

int k = 0;

x1 = 0;

cout << "x=";

cin >> x;

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

{

if (x[i] == '1')

{

k += pow(2, i);

}

}

cout << endl;

cout << "x=" << k << endl;

system("PAUSE");

}

Завдання 7.3

Ввести фамілію, ім’я, по батькові одним рядком. Порахувати довжину кожного слова. Вивести ім’я задом на перед.

#include "stdafx.h"

#include <iostream>

#include <math.h>

#include <conio.h>

#include <stdlib.h>

#include <iomanip>

#include <stdio.h>

#include <time.h>

#include <cstring>

#include <string.h>

#define _CRT_SECURE_NO_WARNINGS

using namespace std;

void _tmain(int argc, _TCHAR* argv[])

{

char st[256];

cin.getline(st, 256);

int Nfam, Nim, Notch;

char * fam = strtok(st, " ");

char * im = strtok(NULL, " ");

char * otch = strtok(NULL, " ");

Nfam = strlen(fam);

Nim = strlen(im);

Notch = strlen(otch);

cout << Nfam << endl;

cout << Nim << endl;

cout << Notch << endl;

char ifam = fam[0];

char iotch = otch[0];

for (int i = 0; i <= strlen(im); i++)

{

cout << im[strlen(im) - i];

}

cout << endl;

system("PAUSE");

}

Практична робота 8 Створення інтерфейсу користувача стандартними подіями

Завдання 8.1

Використовуючи компоненти TRibbon та TActionManager створіть текстовий редактор «WordPad».

//---------------------------------------------------------------------------

#include <vcl.h>

#pragma hdrstop

#include "Unit1.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)

#pragma resource "*.dfm"

TForm1 *Form1;

//---------------------------------------------------------------------------

__fastcall TForm1::TForm1(TComponent* Owner)

: TForm(Owner)

{

}

//---------------------------------------------------------------------------

void __fastcall TForm1::ExitExecute(TObject *Sender)

{

Application->Terminate();

}

//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)

{

ActionList1->Actions[0];

}

//---------------------------------------------------------------------------

void __fastcall TForm1::BoldExecute(TObject *Sender)

{

if (ToolButton1->Down == true)

{

Memo1->Font->Style = Memo1->Font->Style<<fsBold;

}

else

Memo1->Font->Style=Memo1->Font->Style>>fsBold;

}

//---------------------------------------------------------------------------

void __fastcall TForm1::ItalicExecute(TObject *Sender)

{

if (ToolButton2->Down == true)

{

Memo1->Font->Style = Memo1->Font->Style<<fsItalic;

}

else

Memo1->Font->Style=Memo1->Font->Style>>fsItalic;

}

//---------------------------------------------------------------------------

void __fastcall TForm1::UnderlineExecute(TObject *Sender)

{

if (ToolButton3->Down == true)

{

Memo1->Font->Style = Memo1->Font->Style<<fsUnderline;

}

else

Memo1->Font->Style=Memo1->Font->Style>>fsUnderline;

}

//---------------------------------------------------------------------------

void __fastcall TForm1::SizeExecute(TObject *Sender)

{

if (ToolButton4->Down == true)

{

Memo1->Font->Size += 3;

}

}

//---------------------------------------------------------------------------

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]