C语言,试题,答案!
1. 本文由向闯向闯贡献 1编程:要求输入整数a和b,若a*a+b*b大于100,则输出a*a+b*b
百位以上的数字,否则输出两数之和a+b。
#include
main()
{
int a,b,c;
printf("please input a=");
scanf("%d",&a);
printf("please input b=");
scanf("%d",&b);
if(a*a+b*b>100)
{
c=(a*a+b*b)/100;
printf("%d",c);
}
else
printf("%d\n",a+b);
}
2编程:根据以下函数关系:当x<=0,y=0;当020,y=sin(x);输入一个x值,计算出相应的y值并输出。(提示:sin(x)属于math.h) #include
#include
main()
{
int x;
float y;
printf("please input x=");
scanf("%d",&x);
if(x<=0)
{
y=0;
}
else if((0
{
y=x;
}
else if ((10
{
y=10;
}
else
y=sin(x);