主题:关于银行存款最优方式的程序,哪里错了?
#include <stdio.h>
void main()
{
float x,y,max,t;
int N,n1,n2,n3,n4,n5;
N=10000;
for (n5=1;n5<2;n5++)
{ for(n4=1;n4<4;n4++)
{ for(n3=1;n3<6;n3++)
{ for(n2=1;n2<10;n2++)
= { for(n1=1;n1<20;n1++)
{ t=n1+n2+n3+n4+n5;
if (t==20)
{y=N*(1+0.0225)*n1+N*(1+2*0.027)*n2+N*(1+3*0.0324)*n3+N*(1+5*0.036)*n4+N*(1+8*0.04)*n5;
max=y;}
if (max>y)continue;
else max=y;
}}}}}
printf("最大本息和为%.2f\n一年期存%d年\n两年期存%d年\n三年期存%d年\n五年期存%d年\n八年期存%d年\n",max,n1,n2,n3,n4,n5);}
void main()
{
float x,y,max,t;
int N,n1,n2,n3,n4,n5;
N=10000;
for (n5=1;n5<2;n5++)
{ for(n4=1;n4<4;n4++)
{ for(n3=1;n3<6;n3++)
{ for(n2=1;n2<10;n2++)
= { for(n1=1;n1<20;n1++)
{ t=n1+n2+n3+n4+n5;
if (t==20)
{y=N*(1+0.0225)*n1+N*(1+2*0.027)*n2+N*(1+3*0.0324)*n3+N*(1+5*0.036)*n4+N*(1+8*0.04)*n5;
max=y;}
if (max>y)continue;
else max=y;
}}}}}
printf("最大本息和为%.2f\n一年期存%d年\n两年期存%d年\n三年期存%d年\n五年期存%d年\n八年期存%d年\n",max,n1,n2,n3,n4,n5);}