1 solutions

  • 0
    @ 2025-11-5 16:11:51

    C :

    #include<stdio.h>
    #include<math.h>
    int main(){
        double x,y;
        int i,n;
        scanf("%d",&n);
        for(i=1;i<=n;i++){
            scanf("%lf",&x);
            if(x<-2)
              y=x*x-sin(x);
            if(x>=-2&&x<=2)
              y=pow(2,x)+x;
            if(x>2)
              y=sqrt(x*x+x+1);
              printf("%.2lf\n",y);
        }
        return 0;
        }
    

    C++ :

    #include<iostream>
    #include<cstdio>
    #include<cmath>
    using namespace std;
    int main()
    {
    	int n;
    	cin>>n;
    	double x,y;
    	for (int i=1; i<=n; i++)
    	{
    		cin>>x;
    		if (x<-2) y=x*x-sin(x);
    		else if(x>=-2 && x<=2) y=pow(2,x)+x;
    		else y=sqrt(x*x+x+1);
    		printf("%.2lf\n",y);
    	}
    	return 0;
    }
    
    • 1

    2001年秋浙江省计算机等级考试二级C 编程题(1)

    Information

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