#include <stdioh>
#include <mathh>
float f(float x, float y, float z) {
float a = x x + 90f / 40f y y + z z - 1;
return a a a - x x z z z - 90f / 800f y y z z z;}float h(float x, float z) {
for (float y = 10f; y >= 00f; y -= 0001f)
if (f(x, y, z) <= 00f)
return y;
return 00f;}
int main() {
for (float z = 15f; z > -15f; z -= 005f) {
for (float x = -15f; x < 15f; x += 0025f) {
float v = f(x, 00f, z);
if (v <= 00f) {
float y0 = h(x, z);
float ny = 001f;
float nx = h(x + ny, z) - y0;
float nz = h(x, z + ny) - y0;
float nd = 10f / sqrtf(nx nx + ny ny + nz nz);
float d = (nx + ny - nz) nd 05f + 05f;
putchar(":-=+#%@"[(int)(d 50f)]);
}
else
putchar(' ');
}
putchar('\n');
}
}
#include<stdioh>
#include<stringh>
unsigned char code = "12345678";
unsigned char input[56];
int main(void)
{
while(1)
{
printf("请输入密码\n");
scanf("%s", input);
if(strcmp( code, input) == 0)
{
printf("\n");
printf(" 元旦快乐! \n");
printf("\n");
exit(0);
}
}
return 0;
}
#include <reg51h>
sbit speaker=P1^2;
unsigned char timer0h,timer0l,time;
//生日歌
code unsigned char sszymmh[]={5,1,1, 5,1,1, 6,1,2, 5,1,2, 1,2,2, 7,1,4,
5,1,1, 5,1,1, 6,1,2, 5,1,2, 2,2,2, 1,2,4,
5,1,1, 5,1,1, 5,2,2, 3,2,2, 1,2,2, 7,1,2, 6,1,2,
4,2,1, 4,2,1, 3,2,2, 1,2,2, 2,2,2, 1,2,4};
// 音阶频率表 高八位
code unsigned char FREQH[]={
0xF2,0xF3,0xF5,0xF5,0xF6,0xF7,0xF8,
0xF9,0xF9,0xFA,0xFA,0xFB,0xFB,0xFC,0xFC, //1,2,3,4,5,6,7,8,i
0xFC,0xFD,0xFD,0xFD,0xFD,0xFE,
0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFF,
} ;
// 音阶频率表 低八位
code unsigned char FREQL[]={
0x42,0xC1,0x17,0xB6,0xD0,0xD1,0xB6,
0x21,0xE1,0x8C,0xD8,0x68,0xE9,0x5B,0x8F, //1,2,3,4,5,6,7,8,i
0xEE,0x44, 0x6B,0xB4,0xF4,0x2D,
0x47,0x77,0xA2,0xB6,0xDA,0xFA,0x16,
};
void delay(unsigned char t)
{
unsigned char t1;
unsigned long t2;
for(t1=0;t1<t;t1++)
{
for(t2=0;t2<8000;t2++)
{
;
}
}
TR0=0;
}
void t0int() interrupt 1
{
TR0=0;
speaker=!speaker;
TH0=timer0h;
TL0=timer0l;
TR0=1;
}
void song()
{
TH0=timer0h;
TL0=timer0l;
TR0=1;
delay(time);
}
void main(void)
{
unsigned char k,i;
TMOD=1; //置CT0定时工作方式1
EA=1;
ET0=1;//IE=0x82 //CPU开中断,CT0开中断
while(1)
{
i=0;
while(i<75){ //音乐数组长度 ,唱完从头再来
k=sszymmh[i]+7sszymmh[i+1]-1;
timer0h=FREQH[k];
timer0l=FREQL[k];
time=sszymmh[i+2];
i=i+3;
song();
}
}
}
#include<windowsh>
#include<stdioh>
unsigned int rhythm[] = {
0x188, 0x188, 0x1B8, 0x188, 0x20B, 0x1EE,
0x188, 0x188, 0x1B8, 0x188, 0x24B, 0x20B,
0x188, 0x188, 0x310, 0x293, 0x20B, 0x1EE,
0x1B8, 0x2BA, 0x2BA, 0x293, 0x20B, 0x24B,
0x20B
};
unsigned int delay[] = {
0x177, 0x07D, 0x1F4, 0x1F4, 0x1F4, 0x3E8,
0x177, 0x07D, 0x1F4, 0x1F4, 0x1F4, 0x3E8,
0x177, 0x07D, 0x1F4, 0x1F4, 0x1F4, 0x1F4, 0x3E8,
0x177, 0x07D, 0x1F4, 0x1F4, 0x1F4, 0x3E8,
};
void play_music();//奏乐
int main(int argc, char argv[])
{
puts("happy birthday ! \n");
play_music();
return 0;
}
void play_music()
{
int i = 0;
for(; i < 25; ++i)
{
Beep(rhythm[i]5, delay[i]);
if(i == 24)
{
Sleep(500);
i = 0;
}
}
}
以上就是关于用C语言写个代码,利用空格和符号拼写出生日快乐之类的全部的内容,包括:用C语言写个代码,利用空格和符号拼写出生日快乐之类的、谁可以帮我用C语言编一个元旦快乐的程序,要输入密码才能收到祝福的、求: 用51单片机c语言 *** 作使蜂鸣器奏出“祝你生日快乐”音乐的全部程序!等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)