
Добавил:
Studfiles2
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:Лабораторные работы / MyStr / main
.cpp#include "main.h"
int main()
{
char s1[64];
char s2[64];
char s3[64];
setlocale(LC_ALL, "Russian_Russia.866");
CharToOem("Строка 1", s1);
CharToOem("Строка 2", s2);
CharToOem("ро", s3);
MyStr ms1(s1);
MyStr ms2 = s2;
wprintf(L"MyStr ms1(s1);\n");
wprintf(L"MyStr ms2 = s2;\n");
wprintf(L"ms1 = '%hs'; len = %d\n", ms1.GetChar(), ms1.GetLength());
wprintf(L"ms2 = '%hs'; len = %d\n", ms2.GetChar(), ms2.GetLength());
ms2 = ms1;
wprintf(L"ms2 = ms1;\n");
wprintf(L"ms2 = '%hs'; len = %d\n", ms2.GetChar(), ms2.GetLength());
int first_char_index = ms1.FindSubstr(s3);
wprintf(L"int first_char_index = ms1.FindSubstr(s3);\n");
wprintf(L"first_char_index = %d\n", first_char_index);
ms1 = s1;
ms2 = s2;
wprintf(L"ms1 = s1;\n");
wprintf(L"ms2 = s2;\n");
MyStr ms3 = ms1 + ms2;
wprintf(L"ms3 = ms1 + ms2;\n");
wprintf(L"ms3 = '%hs'\n", ms3.GetChar());
ms3 = ms1 + ms1;
wprintf(L"ms3 = ms1 + ms1;\n");
wprintf(L"ms3 = '%hs'\n", ms3.GetChar());
ms3 = ms3 + ms3;
wprintf(L"ms3 = ms3 + ms3;\n");
wprintf(L"ms3 = '%hs'\n", ms3.GetChar());
ms3 = ms3;
wprintf(L"ms3 = ms3;\n");
wprintf(L"ms3 = '%hs'\n", ms3.GetChar());
ms1 = s1;
ms2 = s2;
wprintf(L"ms1 = s1;\n");
wprintf(L"ms2 = s2;\n");
ms2 += ms1;
wprintf(L"ms2 += ms1;\n");
wprintf(L"ms2 = '%hs'\n", ms2.GetChar());
ms3 = static_cast <MyStr> ("a") + "b" + "c" + "d";
wprintf(L"ms3 = static_cast <MyStr> (\"a\") + \"b\" + \"c\" + \"d\";\n");
wprintf(L"ms3 = '%hs'\n", ms3.GetChar());
ms3 += "123";
wprintf(L"ms3 += \"123\";\n");
wprintf(L"ms3 = '%hs'\n", ms3.GetChar());
wprintf(L"ms1 равно ms2? ");
if (ms1 == ms2)
wprintf(L"Да\n");
else
wprintf(L"Нет\n");
ms1 = ms2;
wprintf(L"ms1 = ms2;\n");
wprintf(L"ms1 равно ms2? ");
if (ms1 == ms2)
wprintf(L"Да\n");
else
wprintf(L"Нет\n");
wprintf(L"ms1 не равно ms2? ");
if (ms1 != ms2)
wprintf(L"Да\n");
else
wprintf(L"Нет\n");
MyStr ms4(ms3);
wprintf(L"MyStr ms4(ms3);\n");
wprintf(L"ms4 = '%hs'\n", ms4.GetChar());
wprintf(L"cout << ms4 << endl;\n");
cout << ms4 << endl;
wprintf(L"Введите строку\n");
cin >> ms4;
cout << ms4 << endl;
ms1 = s1;
wprintf(L"ms1 = s1;\n");
ms1.InsertStr(7, "#");
wprintf(L"ms1.InsertStr(7, \"#\");\n");
wprintf(L"ms1 = '%hs'\n", ms1.GetChar());
return 0;
}