哪位仁兄可以用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;
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-01-29
`'.
.`' ` * .
: * *| :
' | || '
`|~'||'
v~v~v~v
!@!@!@!
_!_!_!_!_
| || ||
| || |||
}{{{{}}}{{{
__||__

这个图形行不??我只能办到显示字符画....
或者
iiiiiiiiii
|:H:a:p:p:y:|
__|___________|__
|^^^^^^^^^^^^^^^^^|
|:B:i:r:t:h:d:a:y:|
| |
~~~~~~~~~~~~~~~~~~~追问

能不能把完整的程序发过来 我QQ602345757

追答

还没写,不过我写过类似的
很弱智的。。。

追问

我只是简单的接触过程序设计的语言 这对我来说就很不容易了 麻烦你帮帮忙 谢谢了

追答

好吧,等会加你哦

本回答被提问者采纳
第2个回答  2018-03-06

第3个回答  2012-01-29
没听懂你说的什么意思, 不过用TC的图形库,上网找个几个图片,应该很简单
相似回答