如下是一个动态图的源码,请问如何在中间插入一段文字

#include <stdio.h>

#include <math.h>
#include <windows.h>
#include <tchar.h>
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) <= 0.0f)
return y;
return 0.0f;
}

int main() {
HANDLE o = GetStdHandle(STD_OUTPUT_HANDLE);
_TCHAR buffer[25][80] = { _T(' ') };
_TCHAR ramp[] = _T(".:-=+*#%@");
for (float t = 0.0f;; t += 0.1f) {
int sy = 0;
float s = sinf(t);
float a = s * s * s * s * 0.2f;
for (float z = 1.3f; 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);
}
}

慕的地6264312
浏览 120回答 2
2回答

隔江千里

函数原型:Int pthread_mutex_init(pthread_mutex_t *restrict_mutex,const pthread_mutextattr_t *restrict attr)该函数主要用于多线程中互斥锁的初始化。如果attr为空的话,则是默认属性,而默认属性的快速互斥锁。pthread_mutex_init完成成功后会返回0,其他值都是错误的。int pthread_mutextattr_destroy(pthread_mutextattr_t *restrict_mutext)该函数是销毁线程互斥锁设定互斥锁的作用域:Int pthread_mutextattr_setpshared(pthread_mutexattr_t *restrict mutext, int pshared)在多线程中是共享互斥锁的。如果想在多个进程中共享互斥锁,可以把pshared设置PTHREAD_PROCESS_SHARED如果只想在有同属于一个进程创建的线程中共享互斥锁,则可以把pshared设置为PTHREAD_PROCESS_PRIVATE获得互斥锁的作用域:int pthread_mutexattr_getpshared(pthread_mutexattr_t *restrict mutext,int *pshared);设定互斥锁类型的属性:int pthread_mutexattr_settype(pthread_mutexattr_t *restrict mutext,int type)其中type类型都有:PTHREAD_MUTEX_NOMRAL:此类型的互斥锁不会检测死锁而其中的缺省值值是PTHREAD_MUTEX_DEFAULTPTHREAD_MUTEX_ERRORCHECK:是提供错误检查int pthread_mutexattr_setprotocal(pthread_mutexattr_t *attr,int protocal)protocal可以设置互斥锁属性的协议PTHREAD_PRIO_NONEPTHREAD_PRIO_INHERITPTHREAD_PRIO_PROTECT

慕妹3242003

#includevoidheart(){printf("****\n");printf("****\n");printf("***\n");printf("**\n");printf("**\n");printf("**\n");printf("**\n");printf("**\n");printf("**\n");printf("**\n");printf("**\n");printf("**\n");printf("**\n");printf("**\n");printf("*\n");}intmain(){heart();return0;}
打开App,查看更多内容
随时随地看视频慕课网APP