Mail.ruПочтаМой МирОдноклассникиВКонтактеИгрыЗнакомстваНовостиКалендарьОблакоЗаметкиВсе проекты

Помогите с c++

Ivan lol Ученик (95), открыт 3 дня назад
как на c++ будет программа
(пример на python)
print("hello world")
и
x = 3
print(x)

(если вы сможете то пожалуйста объясните)
3 ответа
etar125 Мыслитель (6254) 3 дня назад
 #include <iostream>
using namespace std;
int main() {
int x = 3;
cout << "Hello, World!" << endl << x << endl;
return 0;
}
Slava Jirov. Оракул (72511) 3 дня назад
Набери на ютубе как написать "Hello World" на с++
Николай Веселуха Высший разум (381897) 3 дня назад
 #include <iostream> 
#include <type_traits>
#include <numbers>

const auto init = []() {
std::cout.setf(std::ios::fixed);
std::cout.precision(15);
return 'c';
}();

struct math {
static constexpr auto pi = std::numbers::pi;
};

template <typename T>
void print_arg(const T& arg) {
if constexpr (std::is_same_v<T, bool>) {
std::cout << (arg ? "TRUE" : "FALSE");
} else {
std::cout << arg;
}
}

void print() {
std::cout << '\n';
}

template<typename T, typename... Args>
void print(T first, Args... args) {
print_arg(first);
if constexpr (sizeof...(args) > 0) {
std::cout << " ";
print(args...);
} else {
std::cout << '\n';
}
}

// почти Python
int main() {
print("Hello world!");
auto x = 3;
print(x);
print("PI:", math::pi);
}
Похожие вопросы