1 条题解

  • 0
    @ 2025-4-14 18:43:48

    C :

    #include <stdio.h>
    #include <math.h>
    #include <stdlib.h>
    #include <time.h>
    int main()
    {
       // freopen("in","r",stdin);
       // freopen("out","w",stdout);
    
        int x;
    	double y;
        while(scanf("%d", &x)!=EOF)
        {
    	if (x > 0)
    	{
    		y = exp(-x);
    	}
    	else if (x == 0)
    	{
    		y = 1;
    	}
    	else
    	{
    		y = -exp(x);
    	}
    	printf("%lf\n", y);
    
    
        }
      return 0;
    }
    
    

    C++ :

    #include<stdio.h>
    #include<math.h>
    int main()
    {
    	int x;
    	float y;
    	while(scanf("%d",&x)!=EOF)
    	{
    		if((x>=-50)&&(x<0))
    		{
    			y = -exp(x);
    		}
    		if((x<=50)&&(x>0))
    		{
    			y = exp(-x);
    		}
    		if(x == 0)
    		{
    			y = 1;
    		}
    		printf("%.6f\n",y);
    	}
        return 0;
    }
    
    
    • 1

    信息

    ID
    3320
    时间
    1000ms
    内存
    128MiB
    难度
    (无)
    标签
    递交数
    0
    已通过
    0
    上传者