关于c语言的一个小创意

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <windows.h>

int t=1,sleeptime=100;
int str0[203]={213,226,202,199,210,187,184,246,185,216,211,218,176,174,181,196,203,192,209,173,187,183,0};
int str1[251]={178,194,178,194,203,252,202,199,202,178,195,180,0};
int str2[189]={196,227,181,196,208,196,192,239,202,199,183,241,210,209,190,173,211,208,193,203,180,240,176,184,0};
int str3[208]={203,252,207,241,178,187,207,241,184,246,198,168,185,201,0};
int str4[210]={040,187,172,187,252,041,0};
int str5[182]={184,248,206,210,210,187,184,246,206,162,208,166,190,205,185,187,193,203,0};
int str6[180]={200,231,177,161,190,198,210,187,177,173,163,172,207,241,200,225,183,231,210,187,194,198,0};
int str7[186]={213,226,190,205,202,199,210,187,198,170,215,238,182,175,200,203,181,196,208,251,209,212,186,199,0};
int str8[189]={183,194,183,240,180,186,204,236,163,172,206,194,220,176,211,214,198,174,210,221,0};
int str9[245]={215,220,211,208,200,203,212,218,177,179,186,243,185,216,208,196,215,197,196,227,0};
int str10[223]={182,254,169,150,210,187,190,197,196,234,163,172,197,174,201,250,189,218,193,244,196,238,0};
int str11[185]={191,236,185,216,193,203,203,252,0};
int str12[000]={};

int str13[]={};

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; 
}


void Slow(const int* string, int sleeptime)
{
    int i=0;
    while(string[i])   
    {			  	      
        printf("%c", string[i]);
        Sleep(sleeptime);
        i++;
    }
    Sleep(sleeptime);
}


void _Something_for_you(){
    int p=1;	
	for (float z = 1.5f; z > -1.5f; z -= 0.05f) {
        for (float x = -1.5f; x < 1.5f; x += 0.025f) {
            float v = f(x, 0.0f, z);
            if (v <= 0.0f) {
                float y0 = h(x, z);
                float ny = 0.01f;
                float nx = h(x + ny, z) - y0;
                float nz = h(x, z + ny) - y0;
                float nd = 1.0f / sqrtf(nx * nx + ny * ny + nz * nz);
                float d = (nx + ny - nz) * nd * 0.5f + 0.5f;
                putchar(".:-=+*#%@"[(int)(d * 5.0f)]);
                Sleep(sleeptime);               
            }
            else
                putchar(' ');    
        }     
        	if(t==10)
            Slow(str1,100);
		    else if(t==14){
		     Slow(str2,100);
			Sleep(1000);
			 }
			else if(t==18){
		 	Slow(str3,200);
		 	Sleep(200);
		 	Slow(str4,200);
			Sleep(3000);
		 }
	         else if(t==26)
            Slow(str5,150);
         	 else if(t==28) 
		    Slow(str6,150);		
			 else if(t==30) 
	     	Slow(str7,150);
			 else if(t==32) 
		    Slow(str8,150);
		    if(t==45){
			Sleep(1000);
	 	 	Slow(str9,100);
				  }
			else if(t==48)
			Slow(str13,100);
         	 else if(t==50){
	 	    Slow(str10,150);  
	 	    Sleep(1000);
			}
			if(p==25&&t>50)
        	Slow(str0,0);
    		if(p==26&&t>50)
  			Slow(str11,0); 	
			++t;	p++;
		 	putchar('\n');
			if(p==52)
			Sleep(3000);
			if(sleeptime>=20) 
			sleeptime-=5;
			else if(t<50)
			sleeptime=1;
			else
			sleeptime=0;
    }
	 
//   second:_Something_for_you();

}

int main() {
	_Something_for_you();
return 0;
}

这段代码是我在看到一篇博客后,产生的创意。

里面加了一些彩蛋,不知道你能不能发现。

内容有些粗糙,希望你别介意。

注意,这段代码仅仅是个创意,希望你看完不会产生什么误会

就这样吧


参考资料:https://blog.csdn.net/creazyandroid/article/details/47724555

猜你喜欢

转载自blog.csdn.net/m0_43456754/article/details/87863991
今日推荐