void getInfo(int& normal_weight, int& weight)
int main()
{
string str; //объявление строки
string str1 = "qwrtpsdfghjklzxcvbnmQWRTPSDFGHJKLZXCVBNM";
cout << "Введите строку: ";
getline(cin,str); //ввод строки
size_t i = 0;
while (i < str.size())
{
if (auto n = str.find_first_of(str1, i); n != string::npos)
{
str.insert(n + 1, 1 ,'!');
i = n + 1;
}
else i += 1;
}
cout << "Изменённая строка: " << str << endl;; //вывод строки
return 0;
}
std::vector<std::string> words; // вектор со словами, начинающимися на одну букву разной длины
words.push_back("A1");
words.push_back("A333");
words.push_back("A22");
// сортировка с кастомным компаратором по возрастанию длины слов
std::sort(words.begin(), words.end(),
[](const std::string& s1, const std::string& s2)
{
return s1.length() < s2.length();
});
// вывод отсортированного вектора
for(auto&& s: words)
std::cout << s << " ";
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdint>
int main()
{
int a = 5;
std::uintptr_t b = reinterpret_cast<std::uintptr_t>(&a);
std::cout << "0x" << std::hex << b << " " << sizeof(b) << std::endl;
std::vector<unsigned char> data(sizeof(b));
for (int i = 0; i < data.size(); i++)
{
data[data.size() - 1 - i] = (b >> (i * 8));
}
for (int i = 0; i < data.size(); i++)
{
std::cout << std::setw(2) << std::setfill('0') << std::hex << (unsigned)data[i] << " ";
}
return 0;
}