用C语言输出心型图案。
网上找到一些编码,有的太小了不漂亮,有的运行有问题。求精简版VC 6.0能运行的代码。
#include #include #include #include float f(float x, float y, float z) { float a = x * x + 9。0f / 4。0f * y * y + z * z - 1; return a * a * a - x * x * z * z * z - 9。
0f / 80。0f * y * y * z * z * z; } float h(float x, float z) { for (float y = 1。0f; y >= 0。0f; y -= 0。001f) if (f(x, y, z) -1。
2f; z -= 0。1f) { _TCHAR* p = &buffer[sy++][0]; float tz = z * (1。2f - a); for (float x = -1。5f; x < 1。5f; x += 0。05f) { float tx = x * (1。
2f + a); float v = f(tx, 0。0f, tz); if (v <= 0。0f) { float y0 = h(tx, tz); float ny = 0。01f; float nx = h(tx + ny, tz) - y0; float nz = h(tx, tz + ny) - y0; float nd = 1。
0f / sqrtf(nx * nx + ny * ny + nz * nz); float d = (nx + ny - nz) * nd * 0。5f + 0。5f; *p++ = ramp[(int)(d * 5。
0f)]; } else *p++ = ' '; } } for (sy = 0; sy < 25; sy++) { COORD coord = { 0, sy }; SetConsoleCursorPosition(o, coord); WriteConsole(o, buffer[sy], 79, NULL, 0); } Sleep(33); } } 。
#include
using namespace std;
#define Mid 29 //等比列放大时 修改这个就行 ,还要修改两个变量的值 下面有标注
const char a = '*';
const char b = ' ';
void main()
{
int Count = 3;// 这个改下 Mid扩大 缩小多少被,这个就扩大缩小多少倍
int Top = (Mid 1)/2;
while(Count)
{
for(int i = 0;i < 2*Count-1;i )
cout << b;
for(int i = 0;i < 16 - (Count 1)*(Count 2)/2;i )
cout << a;
for(int i = 0;i < Count*(Count-1) 1;i )
cout << b;
for(int i = 0;i < 16 - (Count 1)*(Count 2)/2;i )
cout << a;
cout << endl;
Count--;
}
int k = 3;// 这个改下 ,Mid扩大 缩小多少倍,这个就变大或者缩小多少倍,扩大缩小最好不要超过3倍,因为CMD会产生显示问题
while(k)
{
for(int i = 0;i < Mid;i )
cout << a ;
cout << endl;
k--;
Count ;
}
k = Mid - 2;
Count = 0;
while(!(k == -1))
{
for(int i = 0;i < 2*Count 1;i )
cout << b;
for(int i = 0;i < k;i )
cout << a;
cout << endl;
k = k-4;
Count ;
}
for(int i = 0;i < 2*Count;i )
cout << b ;
cout << a << endl;
}
贴上去就能直接用 已经在本机运行成功 不过方法比较笨 我再想想其他简单的 想好告诉你。
答:根据《国家税务总局关于发布的公告》(国家税务总局公告2016年第16 号)第三条规定,一般纳税人出租不动产,按照以下规定缴纳增值税:(一)一般纳税人出租其201...详情>>
问:C语言C语言为了准备三级网络技术上机考试,c语言至少要看到那一章节?
答:数据类型、输入输出、选择语句、循环语句、数组、指针、函数、文件详情>>
答:读指针用来记录文件当前文件之前的读取位置,它指向下一个将要读取的信息项详情>>