PYTHON 3.xx Recursive problem Write a definition of a function named copy that r
ID: 3824036 • Letter: P
Question
PYTHON 3.xx
Recursive problem
Write a definition of a function named copy that reads all of the lines that remain in standard input and displays them in standard output, one on a line with no other spacing.
The function must not use a loop of any kind.
More Hints:
You almost certainly should be using: input
You almost certainly should be using: print
We think you might want to consider using: except
• we think you might want to consider using: =
• We think you might want to consider using: EOFError
Explanation / Answer
#include<iostream>
#include<string>
using namespace std;
string x;
string word;
void copy ()
{
cin>>x;
word+=x+" ";
if(cin.fail())
{
cout<<word<<endl;
}
else
return(copy());
}
int main(){
copy();
cout<<endl;
system("pause");
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.