Программа спрашивает имя и фамилию пользователя, затем выводит их в виде приветствия (например: Hello, Sergey Baranov).
Решение:
Вариант 1
1
2 3 4 5 6 7 8 9 10 11 12 |
#include «stdafx.h»
#include <iostream> using namespace std; void main() {setlocale(LC_ALL,«Russian»); cout<<» What is your name? «; char *name=new char[44]; cin.getline(name, 44); cout<<«Hello, «<<name<<«!»; delete []name; system(«pause>>void»); } |
Вариант 2
1
2 3 4 5 6 7 8 9 10 11 12 |
#include «stdafx.h»
#include <iostream> #include <string> using namespace std; int main() {setlocale(LC_ALL,«Rus»); string name; cout<<» Ваше имя >> «; getline(cin, name); cout<<» Hello, «<<name<<endl; system(«pause»); return 0; } |