⑴ 哪位仁兄可以用c語言幫我寫一個生日快樂的小程序 就是已輸入生日 最後可以出現生日蛋糕的圖像
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
const int inf=0xfffffff ;
int preminv[21] ;
int ri[21],hi[21] ;
int total,floornum ;
int ans ;
int dfs (int n,int v,int s,int maxr,int maxh)
{
int res ;
int i,tmpr,tmph,tmpsum ;
if (n>floornum){
if (v==total && s+ri[1]*ri[1]<ans){
ans = s+ri[1]*ri[1] ;
return 1 ;
}
}
for (ri[n]=maxr-1 ; ri[n]>=floornum-n+1 ; ri[n]--){
res = 2.0*(total-v)/ri[n] + ri[1]*ri[1] ;
if (res + s >= ans) continue ;
for (hi[n]=maxh-1 ; hi[n]>=floornum-n+1 ; hi[n]--){
if (v+ri[n]*ri[n]*hi[n]+preminv[floornum-n]>total) continue ;
tmpr = ri[n] ,tmph = hi[n],tmpsum = 0 ;
for (i=n ; i<=floornum ; i++){
tmpsum += tmpr*tmpr*tmph ;
tmpr-- , tmph-- ;
}
if (v+tmpsum<total) continue ;
dfs(n+1,v+ri[n]*ri[n]*hi[n],s+2*ri[n]*hi[n],ri[n],hi[n]) ;
}
}
return 1 ;
}
int main()
{
int tmpv,tmpr,tmph ;
int i ;
tmpv=0 ;
for (i=1 ; i<21 ; i++){
tmpv += i*i*i ;
preminv[i] = tmpv ;
}
while (scanf("%d%d",&total,&floornum)!=EOF){
ans = inf ;
tmpv = total - preminv[floornum-1] ;
if (tmpv>0){
tmpr = sqrt (1.0*tmpv/floornum) + 1 ;
tmph = 1.0*tmpv/(floornum*floornum) + 1 ;
dfs(1,0,0,tmpr,tmph) ;
}
if (ans==inf){
ans = 0 ;
}
printf("%d\n",ans) ;
}
return 0;
}
⑵ 生日快樂c語言
#include<stdio.h>#include<math.h>floatf(floatx,floaty,floatz){floata=x*x+9.0f/4.0f*y*y+z*z-1;returna*a*a-x*x*z*z*z-9.0f/80.0f*y*y*z*z*z;}floath(floatx,floatz){for(floaty=1.0f;y>=0.0f;y-=0.001f)if(f(x,y,z)<=0.0f)returny;return0.0f;}intmain(){for(floatz=1.5f;z>-1.5f;z-=0.05f){for(floatx=-1.5f;x<1.5f;x+=0.025f){floatv=f(x,0.0f,z);if(v<=0.0f){floaty0=h(x,z);floatny=0.01f;floatnx=h(x+ny,z)-y0;floatnz=h(x,z+ny)-y0;floatnd=1.0f/sqrtf(nx*nx+ny*ny+nz*nz);floatd=(nx+ny-nz)*nd*0.5f+0.5f;putchar(".:-=+*#%@"[(int)(d*5.0f)]);}elseputchar('');}putchar(' ');}}
⑶ 用c語言怎麼寫生日快樂
#include <stdio.h>
#include <math.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() {
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)]);
}
else
putchar(' ');
}
putchar('\n');
}
}
⑷ 跪求一個C語言程序輸出「生日快樂」(TC)
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<windows.h>
chars[8];
voidshow1(char*a)
{
system("cls");
printf("☆☆☆★☆☆☆★☆☆☆★ ");
printf("★☆ ");
printf("☆%s☆ ",a);
printf("☆生日快樂☆ ");
printf("☆★ ");
printf("★☆☆☆★☆☆☆★☆☆☆ ");
Sleep(200);
}
voidshow2(char*a)
{
system("cls");
printf("★☆☆☆★☆☆☆★☆☆☆ ");
printf("☆★ ");
printf("☆%s☆ ",a);
printf("☆生日快樂☆ ");
printf("★☆ ");
printf("☆☆☆★☆☆☆★☆☆☆★ ");
Sleep(200);
}
voidshow3(char*a)
{
system("cls");
printf("☆★☆☆☆★☆☆☆★☆☆ ");
printf("☆☆ ");
printf("☆%s★ ",a);
printf("★生日快樂☆ ");
printf("☆☆ ");
printf("☆☆★☆☆☆★☆☆☆★☆ ");
Sleep(200);
}
voidshow4(char*a)
{
system("cls");
printf("☆☆★☆☆☆★☆☆☆★☆ ");
printf("☆☆ ");
printf("★%s☆ ",a);
printf("☆生日快樂★ ");
printf("☆☆ ");
printf("☆★☆☆☆★☆☆☆★☆☆ ");
Sleep(200);
}
voidtransit(char*a,intn)//將名字的格式轉成4個字。便於排版
{
inti,t;
memset(s,'',sizeof(s));
switch(n)
{
case2:t=3;break;
case4:t=2;break;
case6:t=1;break;
}
for(i=0;i<n;i++)
{
s[t+i]=a[i];
}
}
intmain()
{
intt;
charname[10];
printf("請輸入生日者得姓名(漢字,不要超過3個字): ");
gets(name);
t=strlen(name);
transit(name,t);
while(1)
{
show1(s);
show2(s);
show3(s);
show4(s);
}
return0;
}
⑸ 有一個聖誕快樂的程序據說是用C語言寫的,我想把它改成生日快樂的,跪求原代碼~謝謝各位
#include"stdio.h"
#include <string.h>
intmain(void){
chara[]="Iwishyouahappybirthday!Iwishyouahappybirthday!",m[4],i;
printf("\n\n\n");
printf("%*.*s\n",58,21,"_*=__=*_");
printf("%*.*s\n",61,25,"Wishyourbirthday!");
printf("%*.*s\n",63,29,"Iwishyouahappybirthday!");
printf("%*.*s\n",65,33,a);
printf("%*.*s\n",66,35,a);
printf("%*.*s\n",66,35,a);
printf("%*.*s\n",65,33,a);
printf("%*.*s\n",64,31,a);
printf("%*.*s\n",63,29,a);
printf("%*.*s\n",61,25,a);
printf("%*.*s\n",59,21,a);
printf("%*.*s\n",57,17,a);
printf("%*.*s\n",55,13,a);
printf("%*.*s\n",53,9,a);
printf("%*.*s\n",51,5,a);
printf("%*.*s\n",50,3,a);
printf("%*.*s\n",49,1,a);
return0;
}
(5)c語言如何畫生日快樂擴展閱讀
或者:
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#defineI20
#defineR340
intmain()
{
system("modeconcols=80lines=60");
system("title向你致以最誠摯的祝福!");
chardata[200][60]={{"祝你生日快樂!祝你生日快樂!"},{"\nHappybirthdaytoyou!\n"},{"Happybirthdaymydearfriend!\n"},
{"在你面前的台里本,總有一天是很獨特!\n"},{"雖然你和我,沒辦法選,來到世界的某刻。\n"},{"天氣寒冷,又或炎熱,又或者什麼血型和星座!\n"},
{"每年這刻,我對自己說,有生的日子要更快樂!\n"},{"天氣寒冷,又或炎熱,又或者什麼血型和星座!\n"},{"每年這刻,我對自己說,有生的日子要更快樂!\n"},
{"爸爸媽媽辛苦了!謝謝你們為我付出太多!\n"},{"生日祝福,吹滅蠟燭,我要我自己不許哭。\n"},{"長大了一歲變得靠譜,繼續走自己的旅程!\n"},
{"又到這一個時刻,幸福的花火,手機祝福收到很多很多。\n"},{"看到最後一條來自你,寫著讓我感動的話語。\n"},{"親愛的朋友要經常聯絡,我們一起來唱這首歌!\n"},
{"祝你生日快樂額!我們一起快樂!\n"}
};
intsign=0;
inti,j,e;
inta;
longtime;
for(i=1,a=I;i<I/2;i++,a--)
{
for(j=(int) ( I-sqrt(I*I-(a-i)*(a-i)) );j>0;j--)
printf("");
for(e=1;e<=2*sqrt(I*I-(a-i)*(a-i));e++)
printf("\3");
for(j=(int)
( 2*( I-sqrt(I*I-(a-i)*(a-i)) ) );j>0;j--)
printf("");
for(e=1;e<=2*sqrt(I*I-(a-i)*(a-i));e++)
printf("\3");
printf("\n");
}
for(i=1;i<80;i++)
{
if(i==25)
{
printf("======祝,生日快樂。======");
i+=30;
}
printf("\3");
}
printf("\n");
for(i=1;i<=R/2;i++)
{
if(i%2||i%3)
continue;
for(j=(int) ( R-sqrt(R*R-i*i) );j>0;j--)
printf("");
for(e=1;e<=2*( sqrt(R*R-i*i) - (R-2*I) );e++)
printf("\3");
printf("\n");
}
for(;;)
{
system("colora");
for(time=0;time<99999999;time++); system("color b");
for(time=0;time<99999999;time++); system("color c");
for(time=0;time<99999999;time++); system("color d");
for(time=0;time<99999999;time++); system("color e");
for(time=0;time<99999999;time++); system("color f");
for(time=0;time<99999999;time++);
system("color 0"); for(time=0;time<99999999;time++);
system("color 1"); for(time=0;time<99999999;time++);
system("color 2"); for(time=0;time<99999999;time++);
system("color 3"); for(time=0;time<99999999;time++);
system("color4");
for(time=0;time<99999999;time++); system("color 5");
for(time=0;time<99999999;time++); system("color 6");
for(time=0;time<99999999;time++); system("color 7");
for(time=0;time<99999999;time++); system("color 8");
for(time=0;time<99999999;time++); system("color 9");
for(time=0;time<99999999;time++); system("color ab");
for(time=0;time<99999999;time++); system("color ac");
for(time=0;time<99999999;time++); system("color ad");
for(time=0;time<99999999;time++); system("color ae");
for(time=0;time<99999999;time++); system("color af");
for(time=0;time<99999999;time++);
printf("%s",data[sign]);
sign++;
}
return0;
}