
int sign(int x)
{
int y;
scanf("%d",&x);
if(x>0)
y=1;
else if(x==0)//判断语句是==不是=号
y=0;
else
y=-1;
return y;
}
#include <stdioh>
#include <mathh>
int main(void)
{
int repeat, ri;
double x, y;
scanf("%d", &repeat);
for(ri = 1; ri <= repeat; ri++){
scanf("%lf",&x);
y=x>=0sqrt(x):pow(x+1,2)+2x+1/x;
printf("f(%2f) = %2f\n", x, y);
}
}
这就是个简单的if语句练习啊
double y ;
int x;
if ( x<0 )
{
y=abs(x)/20 ;
}
else if ( x<10 )
{
y=3+exp(x) ;
}
else if ( x< 20 )
{
y = log(x) ;
}
else
然后
1
#include<stdioh>
int main()
{
double x;
while(scanf("%lf",&x) == 1) {
if(x == 0) printf("0\n");
else if(x>0) printf("%lf\n",2x+1);
else printf("%lf\n",1/x);
}
return 0;
}
2
#include<stdioh>
int s[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
int main()
{
int y,m,d,i,sum;
while(scanf("%d %d %d",&y,&m,&d) == 3) {
sum = 0;
for(i = 1;i<m;i++) sum += s[i];
sum += d;
if((y%400 == 0 ||(y%100 !=0 && y%4==0)) && m>2) sum ++;
printf("%d\n",sum);
}
return 0;
}
3
#include<stdioh>
int f(int n)
{
if(n == 1) return 1;
else return nf(n-1);
}
int main()
{
printf("%d\n",f(9)-f(7)+f(5)+f(3));
return 0;
}
#include<stdioh>
int main()
{
int x,y;
scanf("%d",&x);
if(x<-10)
y=0;
else if(x<100) y=5x+1;
else
y = 5x + 1; //这个表达式的值是什么啊
printf("%d\n",y);
return 0;
}
#include <stdioh>
#include <mathh>
double fun(double x)
{
if (x<=0)return(-x+3);
else if(x<1)return 1+xx;
else return 2x+sqrt(x);
}
int main()
{
double x;
scanf("%lf",&x);
printf("y=%lf \n",fun(x));
system("pause");
return 0;
}
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)