
Lv.1
我的昵称一直不敢改,怕你们回来后认不出我了
在 【首届代码岛3.0双创赛】+ 奇妙医院 中回复
加油!
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <windows.h>
#include <tchar.h>
using namespace std;
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() {
cout << "YDS夜晚的星空最棒!" << endl;
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),0x0C);
HANDLE o = GetStdHandle(STD_OUTPUT_HANDLE);
_TCHAR buffer[25][80] = { _T(' ') };
_TCHAR ramp[] = _T(".:-=+*#%@");
int count= 0;
int count1=0;
//system("color F4");
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);
}
if(count <= 10){
printf("I Love You ———.Mua~\n") ;//表白内容
printf(" By 编程爱我");// 表白者的名字
count++;
} else{
printf("You Are My Best Lover.\n");
printf(" Stephen Ge");
count++;
if(count>=20){
count =0;
}
}
Sleep(33);
}
}
2020-02-19T12:29:28 点赞:0
在 【LW说】第一期:用做一个看心术游戏 中回复
这个是自定义函数的代码:
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
void panduan (int i){
if (i<10){
cout << " ";
}
}
int main () {
srand((int)time(NULL));
char x = rand()%13+35;
char shuiji;
for (int i=0 ; i<=99 ; i++){
if (i%9 == 0){
panduan (i);
cout << i << x;
}else {
shuiji = rand()%13+34;
panduan (i);
cout << i << shuiji;
}
if ((i+1)%5 == 0 && i>0){
cout << endl;
}else{
cout << " ";
}
}
cout << "规则:心里像一个十位的整数a,然后把a的十位加上a的个位得到s,再用a-s得的x记住相对应的符号" ;
getchar();
cout << "你心里所想的是不是:" << x << endl;
return 0;
}2020-02-28T12:00:33 点赞:1