1 条题解

  • 0
    @ 2025-4-12 21:47:19

    C :

    #include <stdio.h>
    #include <stdlib.h>
    
    /* run this program using the console pauser or add your own getch, system("pause") or input loop */
    void fun(x)
    {
        //int x;
    	double y;
    	y=x*x-3.14*x-6;
    	printf(" %d\t%.2f",x,y);	
    }
    int main(int argc, char *argv[]) {
    	int x;
    	printf("  x\ty\n");
    	for(x=-10;x<10;x++)
    	{
    		fun(x);
    		printf("\n");
    	}
    	fun(x);
    	return 0;
    }
    

    C++ :

    #include <iostream>
    #include<iomanip>
    
    using namespace std;
    
    double fun(int x);
    int main()
    {
    
    cout<<"  x\ty"<<endl;
    for(int i=-10;i<=10;i++)
    {
    cout<<" "<<i<<"\t"<<fixed<<setprecision(2)<<fun(i)<<endl;
    }
    
    return 0;
    }
    
    double fun(int x)
    {
    double y=(double)x*(double)x-3.14*(double)x-6;
    return y;
    }
    
    • 1

    2012年上半年浙江省高等学校计算机等级考试-编程题2

    信息

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