打印星号(请帮忙) [英] Printing Asterisks (please help)
问题描述
我的编程简介论文将于2013年2月19日开始提供帮助...
我必须在论文之前完成一些程序。
i希望以这种方式打印星星:
* * * * *
。 * * * *
。 。 * * *
。 。 。 * *
。 。 。 。 *
如果我声明一个字符来处理空格,如此字符空间=''。 '';
我可以增加这个空格字符..?!?!?!
例如我写这个:
My paper of Introduction To Programming is going to be help on 19/feb/2013...
I''ve to complete some programs before paper.
i want to print stars in this manner:
* * * * *
. * * * *
. . * * *
. . . * *
. . . . *
what if i declare a character to handle space like this char space = '' . '';
can i increment this space character .. ?!?!?!
For instance i write this:
int main()
{
int length;
cout << "Length: ";
cin >> length;
for (int i = 0; i < length; i++)
{
cout << "* ";
}
cout << endl;
}
我会尽快更新代码,因为我在我的心中会有一些东西..
I WILL UPDATE THE CODE AS SOON AS I GOT SOMETHING IN MY MIND..
推荐答案
试试这个:
for (int a = 5; a > 0; a--)
{
for (int b = 5; b >= a; b--)
{
cout<<".";
}
for (int c = a; c > 0; c--)
{
cout"*";
}
cout<<"\n";
}
希望工作正常
如果你想让它直到用户定义的值,写下包含用户值的变量代替5
Hope it works fine
If you want make it till user defined value, write variable containing the user''s value in place of 5
这篇关于打印星号(请帮忙)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!