1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
program String9;
var
N,i:integer;
C1,C2:char;
S:string;
begin
Write('N:');
Readln (N);
Write('C1:');
Readln (C1);
Write('C2:');
Readln (C2);
S:='';
for i:=1 to (N div 2) do S:=S+C1+C2;
Writeln(S);
end.
Решение Pascal C++
C++
# include <iostream>
# include <windows.h>
# include <cmath>
# include <iomanip>
using namespace std;
const int MAXSIZE = 100;
int main()
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
int N;
char C1, C2;
char str[MAXSIZE] = "";
cout << "Введите символ C1 ";
cin >> C1;
cout << "Введите символ C2 ";
cin >> C2;
cout << "Введите число N ";
cin >> N;
for (int i=0; i<N; ++i){
if (i%2==0) str[i] = C1 ;
else str[i] = C2;
}
str[N]='\0';
cout << str << endl;
system ("pause");
return 0;
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
Объяснение:
Все там правильно написано)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
program String9;
var
N,i:integer;
C1,C2:char;
S:string;
begin
Write('N:');
Readln (N);
Write('C1:');
Readln (C1);
Write('C2:');
Readln (C2);
S:='';
for i:=1 to (N div 2) do S:=S+C1+C2;
Writeln(S);
end.
Решение Pascal C++
C++
# include <iostream>
# include <windows.h>
# include <cmath>
# include <iomanip>
using namespace std;
const int MAXSIZE = 100;
int main()
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
int N;
char C1, C2;
char str[MAXSIZE] = "";
cout << "Введите символ C1 ";
cin >> C1;
cout << "Введите символ C2 ";
cin >> C2;
cout << "Введите число N ";
cin >> N;
for (int i=0; i<N; ++i){
if (i%2==0) str[i] = C1 ;
else str[i] = C2;
}
str[N]='\0';
cout << str << endl;
system ("pause");
return 0;
}
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
# include <iostream>
# include <windows.h>
# include <cmath>
# include <iomanip>
using namespace std;
const int MAXSIZE = 100;
int main()
{
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
int N;
char C1, C2;
char str[MAXSIZE] = "";
cout << "Введите символ C1 ";
cin >> C1;
cout << "Введите символ C2 ";
cin >> C2;
cout << "Введите число N ";
cin >> N;
for (int i=0; i<N; ++i){
if (i%2==0) str[i] = C1 ;
else str[i] = C2;
}
str[N]='\0';
cout << str << endl;
system ("pause");
return 0;
}
Объяснение:
Все там правильно написано)