1 条题解

  • 0
    @ 2025-4-14 18:41:37

    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)

    信息

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