
哪位仁兄可以用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;
}
#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;
}
2012-01-29
展开全部
`'.
.`' ` * .
: * *| :
' | || '
`|~'||'
v~v~v~v
!@!@!@!
_!_!_!_!_
| || ||
| || |||
}{{{{}}}{{{
__||__
这个图形行不??我只能办到显示字符画....
或者
iiiiiiiiii
|:H:a:p:p:y:|
__|___________|__
|^^^^^^^^^^^^^^^^^|
|:B:i:r:t:h:d:a:y:|
| |
~~~~~~~~~~~~~~~~~~~
.`' ` * .
: * *| :
' | || '
`|~'||'
v~v~v~v
!@!@!@!
_!_!_!_!_
| || ||
| || |||
}{{{{}}}{{{
__||__
这个图形行不??我只能办到显示字符画....
或者
iiiiiiiiii
|:H:a:p:p:y:|
__|___________|__
|^^^^^^^^^^^^^^^^^|
|:B:i:r:t:h:d:a:y:|
| |
~~~~~~~~~~~~~~~~~~~
更多追问追答
追问
能不能把完整的程序发过来 我QQ602345757
追答
还没写,不过我写过类似的
很弱智的。。。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
没听懂你说的什么意思, 不过用TC的图形库,上网找个几个图片,应该很简单
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询