Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Zadachi-1.docx
Скачиваний:
0
Добавлен:
01.05.2025
Размер:
27.12 Кб
Скачать

Int main(int argc, char* argv[])

{

cout << "Mesyac" << "\t\t" << "Sezon" << endl;

for (int i = 1; i < 13; i++)

Season(i);

cin.ignore();

cin.get();

return 0;

}

Задача 31.

#include <iostream.h>

#include <math.h>

#include <vcl.h>

#include <string.h>

#include <algorithm>

#pragma hdrstop

using namespace std;

#pragma argsused

string Upper(string str)

{

transform(str.begin(), str.end(), str.begin(), toupper);

return str;

}

Int main(int argc, char* argv[])

{

string str = "\"Happy new 2012 year!\"";

str = Upper(str);

cout << str << endl;

cin.ignore();

cin.get();

return 0;

}

Задача 32.

#include <iostream.h>

#include <math.h>

#include <vcl.h>

#include <string.h>

#include <algorithm>

#pragma hdrstop

using namespace std;

#pragma argsused

string Upper(string str)

{

transform(str.begin(), str.end(), str.begin(), tolower);

return str;

}

Int main(int argc, char* argv[])

{

string str = "\"Happy New Year!\"";

str = Upper(str);

cout << str << endl;

cin.ignore();

cin.get();

return 0;

}

Задача 33.

#include <iostream.h>

#include <math.h>

#include <vcl.h>

#include <string.h>

#include <algorithm>

#pragma hdrstop

using namespace std;

#pragma argsused

string Upper(string str)

{

for (int i = 0; i < str.size(); i++)

{

int code = str[i];

if (code >= 65 && code <= 90)

{

code += 32;

str[i] = (char)code;

}

else

if (code >= 97 && code <= 122)

{

code -= 32;

str[i] = (char)code;

}

}

return str;

}

Int main(int argc, char* argv[])

{

string str = "\"Happy New Year!\"";

str = Upper(str);

cout << str << endl;

cin.ignore();

cin.get();

return 0;

}

Задача 34.

#include <iostream.h>

#include <math.h>

#include <vcl.h>

#include <string.h>

#include <algorithm>

#pragma hdrstop

using namespace std;

#pragma argsused

int StrSumma(string str)

{

int sum = 0;

for (int i = 0; i < str.size(); i++)

{

int code = str[i];

if ((code >= 65 && code <= 90) || (code >= 97 && code <= 122))

sum += i;

}

return sum;

}

Int main(int argc, char* argv[])

{

string str = "\"BNTU!\"";

cout << "Summa: " << StrSumma(str) << endl;

cin.ignore();

cin.get();

return 0;

}

Задача 35.

#include <iostream.h>

#include <math.h>

#include <vcl.h>

#include <string.h>

#include <algorithm>

#pragma hdrstop

using namespace std;

#pragma argsused

string Slovo(string str, int num)

{

int index = 0;

while (num != 1)

if (str[index++] == ' ')

num--;

string word;

word = str.substr(index, str.length());

return word;

}

Int main(int argc, char* argv[])

{

string str = "\"Happy New Year!\"";

cout << "Slovo: " << Slovo(str, 3) << endl;

cin.ignore();

cin.get();

return 0;

}

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