+ 1
make This smaller?
https://code.sololearn.com/c1h37yDst4Ft/?ref=app I only know a few about c++, anyone knows to make this code shorter?
4 Réponses
+ 5
Navaneeth,
For make the code shorter, just use a `for loop` instead of a `while loop`.
See this code& learn..
https://code.sololearn.com/cTm4vMheox4i/?ref=app
And for your second question:
Learn c++ course with carefully..
https://www.sololearn.com/learn/courses/c-plus-plus-intermediate
https://www.sololearn.com/learn/courses/c-plus-plus-intermediate
+ 1
#include<iostream>
using namespace std;
int main()
{
int x, l;
cout<<"enter no.of lines: ";
cin>>l;
cout<<"\n\n";
for(x=1;l;x+=2,l--)
cout<<string(l,' ')+string(x,'*')<<endl;
}
0
.. and why cout<<"*" *3 ; doesn't print *** like python?
0
thanks