0
How to make string stay on the same line
input: 3 output: &&& | | | what i get: & | & | & | I think that there should be some kind of operator for this but i im a total noob so i dont know it. thanks in advance
3 ответов
+ 1
It would be great, if you can provide your code :) But it looks like you are outputting '&', then '|' 3 times and after each one is new line. That can be caused by character '\n', or endl in cout << endl. I don't know if I got your question right.
This should output
&&&
|||
if you input 3:
int n;
cin >> n;
for(int i = 0; i < n; i++)
cout << '&';
cout << endl;
while(n--)
cout << '|';
cout << endl;
0
hii if i m not wrong ur coding will become an infinite loop as n>0 is not specified but i like coding
0
Yes, you're right :) But that is just illustration, program will crash also if you input string instead of integer, but I hope everybody gets the idea :)