借此熟悉一下编程,呵呵,好长时间都没编了!希望大家给点建议吧!~
#include<stdio.h>
#define MONEY 100
int main(void)
{
int gj,mj, xj;
int max_mj=0,m_g,m_x,count=0;
for(gj=0;gj<=(int)MONEY/3;gj++)
for(mj=0;mj<=(int)MONEY/5;mj++)
for(xj=0;xj<=(int)MONEY*3;xj++)
if(xj%3==0)
{
if(((3*gj+5*mj+xj/3)==100)&&((gj+mj+xj)==100))
{
count++;
printf("%d,%d,%d\n",gj,mj,xj);
if(max_mj<=mj)
{
max_mj=mj;
m_g=gj;
m_x=xj;
}
}
}
printf("The number of buy:\n%d\n",count);
printf("The way to buy the most of MJ:\n");
printf("%d,%d,%d"" (m_g,max_mj,m_x)\n",m_g,max_mj,m_x);
return 0;
}