有cprintf的替代品吗?
我试图用星号“*”画一棵圣诞树,最后我能够画一棵。
问题是当我使用 textattr(130) 给它着色时“这个颜色是闪烁的绿色”& cprintf 函数中的树分散在整个屏幕上。
我画了一条垂直线来看看cprintf的效果。
除了 cprintf 之外,我可以使用任何其他方法,我只是希望树能够正确显示并着色。
我的代码是:
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
textattr(130);
cprintf("*"
"\n*"
"\n*"
"\n*"
"\n*"
"\n*"
"\n*"
"\n*"
"\n*"
"\n*");
cprintf(
"\n *"
"\n * *"
"\n * *"
"\n * *"
"\n * *"
"\n ** **"
"\n * *"
"\n * *"
"\n * *"
"\n ** **"
"\n * *"
"\n * *"
"\n * *"
"\n * *"
"\n ****** ******"
"\n * *"
"\n * *"
"\n * *"
"\n * *"
"\n ***");
getch();
return 0;
}
我希望有人愿意帮助我解决这个问题。
I am trying to draw a Christmas tree using astrics "*" and at last I was able to draw one.
The problem is when I colored it using textattr(130) "this color is GREEN with blinking" & cprintf functions the tree was scattered all over the screen.
I drew a vertical line to see the effect of cprintf.
I am ok with any other methods other than cprintf, I just hope for the tree to be displayed right and colored.
My code is:
#include<stdio.h>
#include<conio.h>
int main()
{
clrscr();
textattr(130);
cprintf("*"
"\n*"
"\n*"
"\n*"
"\n*"
"\n*"
"\n*"
"\n*"
"\n*"
"\n*");
cprintf(
"\n *"
"\n * *"
"\n * *"
"\n * *"
"\n * *"
"\n ** **"
"\n * *"
"\n * *"
"\n * *"
"\n ** **"
"\n * *"
"\n * *"
"\n * *"
"\n * *"
"\n ****** ******"
"\n * *"
"\n * *"
"\n * *"
"\n * *"
"\n ***");
getch();
return 0;
}
I hope someone would like to help me with this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我拿了你的程序并参考了这个并提出了下面的程序。
I took your program and referred to this and came up with the below program.
您可以使用 setcolor() 函数来更改文本的颜色。下面的示例程序解释了它的用法。
You can use the setcolor() function in order to change the color of your text. The following sample program explains its usage.