@anmartex
...
1708 / 1201 / 497
Регистрация: 12.02.2013
Сообщений: 1,978
|
22.02.2013, 04:55
|
|
C++ | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
| #include <iostream>
#include <sstream>
#include <string>
void Print(char ch, unsigned size)
{
while (size--)
{
std::cout << ch;
}
}
void Print(char ch, unsigned first, unsigned second)
{
Print(' ', first);
Print(ch, second - first);
}
int main()
{
std::cout << "Input data: ";
std::string line;
std::getline(std::cin, line);
std::stringstream sstream;
sstream << line;
char ch = 0;
unsigned first = 0, second = 0;
sstream >> ch >> first >> second;
if ((ch == 0) || (first == 0))
{
std::cerr << "Usage: CHAR DIGIT1 <DIGIT2>\n"
<< " if use DIGIT2 then must be DIGIT1 < DIGIT2"
<< std::endl;
return 1;
}
if (second == 0)
{
Print(ch, first);
}
else
{
Print(ch, first, second);
}
return 0;
} |
|
0
|