1. 代碼如下,3)需要實際運(yùn)行時輸入測試
在番禺等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強(qiáng)發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供網(wǎng)站設(shè)計、成都網(wǎng)站設(shè)計 網(wǎng)站設(shè)計制作定制網(wǎng)站制作,公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),成都品牌網(wǎng)站建設(shè),成都營銷網(wǎng)站建設(shè),外貿(mào)網(wǎng)站建設(shè),番禺網(wǎng)站建設(shè)費用合理。
int main(void)
{
double x, y, f;
printf("Please input 2 double number in the form of x y:\n");
scanf("%lf%lf", x, y);
if(x=0 y0)
f = 2*x*x + 3*x +1/(x+y);
else if(x=0 y=0)
f = 2*x*x + 3*x +1/(1+y*y);
else
f = 3*sin(x+y)/(2*x*x) + 3*x + 1;
printf("x=%lf, y=%lf, f(x, y)=%lf\n", x, y, f);
return 0;
}
2.代碼如下
#include stdio.h
#includemath.h
int main(void)
{
double x, y, f;
printf("Please input 2 double number in the form of x y:\n");
scanf("%lf%lf", x, y);
if(x=0)
{
if(y0)
f = 2*x*x + 3*x +1/(x+y);
else
f = 2*x*x + 3*x +1/(1+y*y);
}
else
f = 3*sin(x+y)/(2*x*x) + 3*x + 1;
printf("x=%lf, y=%lf, f(x, y)=%lf\n", x, y, f);
return 0;
}
3.代碼如下
#include stdio.h
int main(void)
{
int score = 0;
printf("Please input a score between 0-100:\n");
scanf("%d", score);
if(score0 || score100)
printf("Wrong input of score!\n");
else if(score=90 score=100)
printf("A\n");
else if(score=80 score=89)
printf("B\n");
else if(score=70 score=79)
printf("C\n");
else if(score=60 score=69)
printf("D\n");
else
printf("E\n");
return 0;
}
#include?stdio.h?
int?main()?
{double?x,y;
scanf("%lf",x);
if(x0)y=x*x-1;
else?if(x1)y=x*x;
else?y=x*x+1;
printf("%g",y);
return?0;?
}
#include
int?main()
{
int?x,y;
scanf("%d",x);
if(0xx10)?y=3*x+2;
else
{if(x=0)?y=0;
else
{if?(x0)?y=x*x;
else?printf("go?die\n");
}
}
printf("%d",y);
return?0;
}該程序的分段函數(shù)如下:
f(x)=3x+2? (0x10)
f(x)=1???????? (x=0)
f(x)?=?x*x??? (x0)
#include stdio.h
#include math.h
void main()
{
float x;
double y;
printf("Please input the value of x:");
scanf("%f",x);
if(x=-10x=4)
{
y=fabs(x-2);
printf("y=%.2f\n",y);
}
else if(x=5x=7)
{
y=x+10;
printf("y=%.2f\n",y);
}
else if(x=8x=12)
{
y=pow(x,4);
printf("y=%.2f\n",y);
}
else
printf("No answer\n");
}
幫你改了下代碼,VC6測試通過,自己看看吧。
#includestdio.h
int main()
{
float x,y;//根據(jù)給定的測試用例,x,y應(yīng)該為float型
scanf("%f",x);//x為float型,所以改為%f
if(x20)
{
y=x+100;
}
else if(x=20x=100)
{
y=x;
}
else
y=x-100;
printf("x=%f,y=%f\n",x,y);
return 0;//缺少分號
}
/*
copyright\c)2017,csdn學(xué)院
*All cights reserved
*文件名稱:a.c
*作者:王琦
*完成日期:2017年7月7日
*版本號:6.0
*問題描述:求解分段函數(shù)的值
*程序輸出:分段函數(shù)的值
*/
#include stdio.h
double f(double n)
{
double j;
if(n0.3)
j=0;
else if(n0.8)
j=(n-0.3)/(0.8-0.3);
else
j=1;
return(j);
}
int main( )
{
double x;
printf("請輸入x的值:");
scanf("%lf", x);
printf("解得:f(%.2f)=%.2f\n", x, f(x));
}