0
Does anyone know how to write a code which comes out like a list in C++
A code which brings an output like this Line. Asterisk 1. * 2. ** 3. *** 4. **** 5. ***** 6. ****** 7. ***** 8. **** 9. *** 10. ** 11. *
18 odpowiedzi
0
Please help put
0
Have you tried to solve the task? Can you show us that attempt?
0
Okay sure
0
#include <iostream>
Using namespace std;
int main()
{
cout<<"Line"<<endl;
for(int x=1;x<=19;x++){
cout<< x <<endl;
}
int row=0;
int nasterisk;
for(row=1;row<=10;row++){
nasterisk;
cout<<"\t\t";
for(nasterisk=1;nasterisk<=row;nasterisk++){
cout<<"*";
cout<<endl;
}
for(row=9; row>=0;row--){
cout<<"t\t\";
for(nasterisk=1;nasterisk<=row;nasterisk++)
cout<<"*";
cout<<endl;
}
}
system("pause");
return 0;
}
0
This is the code
0
There is some bugs and the code is too long
0
Some bugs like?
0
Try to put in the code
0
How? I don't understand
0
#include <iostream>
#include<iomanip>
using namespace std;
int main() {
int line;
cin>>line;
for(int i=0;i<line;i++){
cout<<left<<setw(4)<<i+1;
for(int j=0;j<=(i<=line/2? i:line-i-1);j++){
cout<<"*";
}
cout<<endl;
}
return 0;
}
0
That's would work
0
Because you cout line before asterisk not with it
That's first
0
Mohamed ELomari did you see line number 11 and 12 in output of your code?
0
No
0
Thanks it worked out
0
#include <iostream>
using namespace std;
int d;
int main() {
for(int i=-4;i<=4;i++){ d=5-abs(i);
for(int j=0;j<d;j++)
cout<<"*"; //use printf("*");
cout<<endl;}//use printf("/n");
return 0;
}// abs function is return positive value