1 solutions

  • 0
    @ 2025-11-5 16:59:33

    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

    Information

    ID
    18122
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By