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);