爱问知识人 爱问教育 医院库

用C语言输出心型图案。

首页

用C语言输出心型图案。

网上找到一些编码,有的太小了不漂亮,有的运行有问题。求精简版VC  6.0能运行的代码。

提交回答

全部答案

    2018-06-09 21:01:22
  •   #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); } } 。

    时***

    2018-06-09 21:01:22

  • 2018-06-09 05:27:42
  •   #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;
    }
    贴上去就能直接用 已经在本机运行成功 不过方法比较笨 我再想想其他简单的 想好告诉你。
      

    生***

    2018-06-09 05:27:42

类似问题

换一换

相关推荐

正在加载...

热点检索

  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 175-194
返回
顶部
帮助 意见
反馈

确定举报此问题

举报原因(必选):