+ 2

Please help to code this

I made a code for rectangular pattern but I want it should be a parallelogram. It is printing like for n=5 ***** * * * * * * ***** But I want it should print like ***** * * * * * * ***** Suggest me the way. Thanks in advance.... https://code.sololearn.com/cEBArpjxySFZ/?ref=app

18th Aug 2019, 9:42 AM
Ankul Chaudhary
Ankul Chaudhary - avatar
2 Antworten
+ 2
i edited your code a little and made it (at least for me) simpler, it now does parallelograms: #include <iostream> using namespace std; int main(){ int n; cin>>n; cout<<"Your number is "<<n<<endl; for(int i=0;i<n-1;i++){ cout<<" "; } for(int i=0;i<n;i++){ cout<<"*"; } cout<<endl; for(int i=0;i<n-2;i++){ for(int j=0;j<n-i-2;j++){ cout<<" "; } cout<<"*"; for(int k=0;k<n-2;k++){ cout<<" "; } cout<<"*"<<endl; } for(int j=0;j<n;j++){ cout<<"*"; } return 0; }
18th Aug 2019, 10:02 AM
Anton Böhler
Anton Böhler - avatar
+ 2
Thanks for help brother😄😄...
18th Aug 2019, 10:41 AM
Ankul Chaudhary
Ankul Chaudhary - avatar