АРТЕ А АРТЕ Регистрация 9 Ноя 2013 Сообщения 90 Репутация 0 Спасибо 0 Монет 0 1 Янв 2025 #1 Суть такова, после C# решил начать изучать плюсы, но встал на на моменте записи ввода для вывода в консоль. В C# для этого было достаточно (самый простой пример): Int age = Convert.ToInt32(Console.ReadLine()); То в плюсах не могу разобраться как сделать это
Суть такова, после C# решил начать изучать плюсы, но встал на на моменте записи ввода для вывода в консоль. В C# для этого было достаточно (самый простой пример): Int age = Convert.ToInt32(Console.ReadLine()); То в плюсах не могу разобраться как сделать это
илья2341 И илья2341 Регистрация 30 Ноя 2012 Сообщения 92 Репутация 0 Спасибо 0 Монет 0 1 Янв 2025 #2 int age; std::cin >> age;
hfba H hfba Регистрация 19 Ноя 2013 Сообщения 80 Репутация 0 Спасибо 0 Монет 0 1 Янв 2025 #3 int age; std::cin >> age;
Maks22 M Maks22 Регистрация 17 Ноя 2013 Сообщения 87 Репутация -1 Спасибо 0 Монет 0 1 Янв 2025 #4 #include <iostream> #include <string> using namespace std; const auto init = []() { system("chcp 1251 > nul" return 'c'; }(); struct Console { struct Convert { static int ToInt32(const string& value) { return stoi(value); } }; static string ReadLine() { string line; getline(cin, line); return line; } static int ReadKey() { return cin.get(); } template<typename T> static void WriteLine(const string& prompt, const T& value) { cout << prompt << value << '\n'; } static void Write(const string& prompt) { cout << prompt; } }; int main() { Console::Write("Введите возраст: " auto age = Console::Convert::ToInt32(Console::ReadLine()); Console::WriteLine("Возраст: ", age); Console::ReadKey(); }
#include <iostream> #include <string> using namespace std; const auto init = []() { system("chcp 1251 > nul" return 'c'; }(); struct Console { struct Convert { static int ToInt32(const string& value) { return stoi(value); } }; static string ReadLine() { string line; getline(cin, line); return line; } static int ReadKey() { return cin.get(); } template<typename T> static void WriteLine(const string& prompt, const T& value) { cout << prompt << value << '\n'; } static void Write(const string& prompt) { cout << prompt; } }; int main() { Console::Write("Введите возраст: " auto age = Console::Convert::ToInt32(Console::ReadLine()); Console::WriteLine("Возраст: ", age); Console::ReadKey(); }
aadd11 A aadd11 Регистрация 10 Июл 2013 Сообщения 77 Репутация 6 Спасибо 0 Монет 0 1 Янв 2025 #5 #include <windows.h> #include <string> #include <iostream> #include <math.h> #include <iomanip> #include <vector> using namespace std; //и можно std:: не писать int main(int argc, char **argv) { system("chcp 1251 > nul" // Руссификация сообщений setlocale(LC_ALL, "Russian" cout << endl << "Хелло Ворлд" << endl; system("pause" // system("pause > nul" return 0; } шаблон консоли
#include <windows.h> #include <string> #include <iostream> #include <math.h> #include <iomanip> #include <vector> using namespace std; //и можно std:: не писать int main(int argc, char **argv) { system("chcp 1251 > nul" // Руссификация сообщений setlocale(LC_ALL, "Russian" cout << endl << "Хелло Ворлд" << endl; system("pause" // system("pause > nul" return 0; } шаблон консоли