如何在C++中使用星号(*)绘制V字母形状
How to Draw V Letter Shape Using Asterisk(*) in C++
我想在C++中画一个字符 V。我不知道该怎么做才能获得所需的结果。
#include <iostream.h>
using namespace std;
int main()
{
int i, j;
for()
{
for()
{
if(i == j)
{
cout << "*";
}
else
{
cout << " ";
}
}
cout<< endl;
return 0;
}
int main()
{
std::cout << "* *n"
" * *n"
" * *n"
" **n"
}
我不是C++的忠实粉丝,但我试图给出逻辑
#include <iostream.h>
using namespace std;
int main() {
int n; //height of the Char V
int i, j;
#char s=""; //i know only to adding string if u add s as string
for(int x = 1, y = n ; x <= y ; x++, y--) {
cout << s;
cout << "*";
for(int t = 1 ; t < t ; t++) {
cout << "";
}
cout << "*";
s=s+"";
}
cout << endl;
return 0;
}
private static void drawPattern(int height) {
// TODO Auto-generated method stub
int end=height * 2;
int j=0;
for ( int start=0;start<height;start++,end--) {
for ( j=0;j<start;j++){
System.out.print(" ");
}
System.out.print("*");
for ( ;j<end;j++) {
System.out.print(" ");
}
System.out.println("*");
}
}
JAVA中的一个脏实现,尝试移植到C++,高度可以由用户输入
相关文章:
- QuadTree只在窗口的右上角绘制
- 绘制旋转的三角形
- flutter:即使shouldRepaint()返回true,自定义画家也不会重新绘制
- 如何在QT中的自定义视频小工具t上绘制矩形
- 如何在Visual Basic中使用矩形函数OpenGL绘制矩形
- 无法使用VAO和EBO(openGL)绘制多个对象
- 为什么我的点没有在 OpenGL 中绘制鼠标所在的位置?
- 绘制顺时针三角形,重新排序点
- 在顶点着色器中使用 OpenGl 的未声明标识符,我在顶点着色器中绘制三角形时遇到问题
- SFML 文本未绘制在窗口上
- 如何在快板的屏幕中显示子位图的绘制?
- 如何绘制自定义形状的元素?
- QPainter 将 QBrush 设置为 在 QT/C++ 中绘制文本
- 除非重新绘制大小,否则SDL_Texture在调整大小后呈现黑色
- 绘制文本问题
- 在 QT C++中绘制/操作多边形
- 如何在 Gnuplot 中分别绘制 2 个文件数据?我有一个文件"sin.txt",另一个文件"cos.txt",我想将它们分别绘制在一个图表上
- 在现代OpenGL中,绘制GL_TRIANGLE奇怪的z轴行为的填充圆
- OpenGL 着色器不绘制任何东西 - 糟糕的精灵类
- 要在屏幕上绘制一些小瓷砖,我应该使用 QQuickItem 还是 QQuickPaintedItem?