#include <sstream>
#include <vector>
#include <iostream>
int main(void) {
std::string inputString = "a b c 1 2 3";
const char kDelim = 0x20; // Пробел
std::vector<std::string> result;
std::stringstream ss(inputString);
std::string item;
while (getline(ss, item, kDelim)) {
result.push_back(item);
}
for (const auto& e:result)
{
std::cout << "Аргумент: " << e << "\n";
}
return 0;
}
#include <iostream>
using namespace std;
int main()
{
int num1, num2, width, height, attitude, S;
cout << "Enter the first number: ";
cin >> num1;
cout << "Enter the second number: ";
cin >> num2;
if ((num1 >= 2) && (num1 <= 100))
{
if (num1 <= 50)
{
width = num1;
height = num2;
cout << width;
}
else
{
height = num1;
width = num2;
}
} else {
cout << "The number must be > 2 and < 100";
}
}
#include <iostream>
#include <stdexcept>
double func(double a, double b, double c)
{
double d = b * b - 4 * a * c;
if (d < 0) {
throw std::runtime_error("d < 0");
}
return d;
}
int main()
{
double a = 1.0;
double b = 2.0;
double c = 3.0;
double d;
try {
d = func(a, b, c);
std::cout << "d = " << d << "\n";
} catch (const std::exception& e) {
std::cout << "ERROR: " << e.what() << "\n";
}
std::cout << "Press any key...";
std::cin.get();
}