#include <iostream>
using namespace std;
void drawLine(int N){
if(N == 0)
return;
cout << '-';
drawLine(N - 1);
}
int main(){
int n;
cin >> n;
drawLine(n);
Нерекурсивный вариант:
void Write_Line(int n) {
string s;
for (int i = 0; i < n; ++i)
s += '-';
cout << s;
int main() {
Write_Line(n);
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Verified answer
#include <iostream>
using namespace std;
void drawLine(int N){
if(N == 0)
return;
cout << '-';
drawLine(N - 1);
}
int main(){
int n;
cin >> n;
drawLine(n);
}
Нерекурсивный вариант:
#include <iostream>
using namespace std;
void Write_Line(int n) {
string s;
for (int i = 0; i < n; ++i)
s += '-';
cout << s;
}
int main() {
int n;
cin >> n;
Write_Line(n);
}