急求C语题答案!!!

来源:百度知道 编辑:UC知道 时间:2024/06/17 07:45:51
1.已知公鸡5元一只,母鸡3元一只,小鸡一元3只,先要用100块钱买100只鸡,编写程序,求可能出现的情况。
2.利用数组编写程序,存储5名同学的数学,语文,外语成绩。并输出。

百元百鸡
#include <stdio.h>
main()
{
int i,j,k;
printf("The plan:\n");
for(i=0;i<20;i++)
{for(j=0;j<33;j++)
for (k=0;k<100-i-j; k++)
{ if(5*x+3*y+z*3==100)
printf("chicken=%5d hen=%5d cock%5d\n",x,y,z);
}
}

}
呵呵 一楼第一题出了点问题 我已经改了下
这次应该对了
至于第二题 对了 我也不说什么了 .....

#include <stdio.h>//百元百鸡
main()
{
int x,y,z;
printf("The plan:\n");
for(x=0;x<20;x++)
for(y=0;y<33;y++)
{
z=100-x-y;
if(5*x+3*y+z/3==100)
printf("chicken=%4d hen=%4d cock%4d\n",x,y,z);
}

}

#include <stdio.h>//学生成绩输入输出
struct student
{
float chinese,math,english;
}s[5];
main()
{
int i;
for(i=0;i<5;i++)
{
printf("Input the %dth student's scores:\n&