C语言编程,跪求答案!!!!

来源:百度知道 编辑:UC知道 时间:2024/05/31 08:10:48
公鸡5元一只,母鸡3元一只,小鸡一元3只,100元买100鸡,求有多少中买法并输出所有可能的买法?,,,,

还有几道题,,,我用我全部的分请求高手给我答案,,,

1.计算分段函数的值
-x 0≤x<10
1+ 10≤x<20
x-3 20≤x<40
x2 40≤x<50
#include <stdio.h>
main()
{ float x;y;
printf("Input a data:");
scanf("%d",&x);
if (x<0 && x>=50 ) printf("Input error!\n");
else { if (0≤x<10) y=-x;
else if (x<20) y=1+1/4x;
else if (x<40) y=x-3.0;
if (x<50) y=x2;
printf("x=%.2f,y=%.1f\n",x,y);
}
}
2.从键盘输入两个整数,按由小到大输出,程序如下:
void main( )
{float a,b;
scanf(”%d,%d”,a,b);
if ( a<=b) swap(&a,&b);
printf(”%d,%d”,a,b);
}
int swap(int x,int y)
{int t;
t= x; x= y; y=

问世间情为何物,只叫人生死相随!

#include<stdio.h>
int main(void)
{
int i,r,m;
for(i=1;i<20;i++)
for(r=1;i<33;r++)
{
m=100-i-r;
if((i*5+r*3+m/3==100)&&m%3==0)
printf("%d %d %d\n",i,r,m);
return 0;
}
}

其它问是要找错?

我在那边的回答 哪里不对吗?

告诉我哈

一楼的想法 很不错 顶一下!!

#include "stdio.h"
void main()
{
int i=1,j,k;
printf("gongji muji xiaoji\n");
for(;i<20;i++)
for(j=1;j<33;j++)
{
k=100-i-j;
if((i*5+j*3+k/3==100)&&k%3==0)
printf("%5d%5d%5d\n",i,j,k);
}
}

1.
#include <stdio.h>
main()
{ float x;y;/*x后面的分号改为逗号*/
printf("Input a data:");
scanf("%d",&x);
if (x<0 && x>=50 ) printf("Input error!\n"); /*两个&号改