zoukankan      html  css  js  c++  java
  • openjudge1.3

    1.3.1

    描述
    在大部分的在线题库中,都会将A+B问题作为第一题,以帮助新手熟悉平台的使用方法。

    A+B问题的题目描述如下:给定两个整数A和B,输出A+B的值。保证A、B及结果均在整型范围内。

    现在请你解决这一问题。

    #include<iostream>
    using namespace std;
    int main()
    {
    	int a,b,c;
    	cin>>a>>b;
    	c=a+b;
    	cout<<c;
    	return 0; 
    }
    

    1.3.2

    描述
    给定3个整数a、b、c,计算表达式(a+b)*c的值。

    #include<iostream>
    using namespace std;
    int main()
    {
    	int a,b,c,d;
    	cin>>a>>b>>c;
    	d=(a+b)*c;
    	cout<<d;
    	return 0; 
    }
    

    1.3.3

    描述
    给定3个整数a、b、c,计算表达式(a+b)/c的值,/是整除运算。

    #include<iostream>
    using namespace std;
    int main()
    {
    	int a,b,c,d;
    	cin>>a>>b>>c;
    	d=(a+b)/c;
    	cout<<d;
    	return 0; 
    }
    

    1.3.4

    描述
    给定被除数和除数,求整数商及余数。

    此题中请使用默认的整除和取余运算,无需对结果进行任何特殊处理。看看程序运行结果与数学上的定义有什么不同?

    #include<iostream>
    using namespace std;
    int main()
    {
    	int a,b,c,d;
    	cin>>a>>b;
    	c=a/b;
    	d=a%b;
    	cout<<c<<" "<<d;
    	return 0; 
    }
    

    1.3.5

    描述
    两个整数a和b分别作为分子和分母,既分数 a/b ,求它的浮点数值(双精度浮点数,保留小数点后9位)

    #include<cstdio>
    using namespace std;
    int main()
    {
         double a,b,c;
         scanf("%lf%lf",&a,&b);
         c=a/b;
         printf("%.9lf",c);
         return 0;
    }
    

    1.3.6

    描述
    甲流并不可怕,在中国,它的死亡率并不是很高。请根据截止2009年12月22日各省报告的甲流确诊数和死亡数,计算甲流在各省的死亡率

    #include<cstdio>
    using namespace std;
    int main()
    {
         double a,b,c;
         scanf("%lf%lf",&a,&b);
         c=100*b/a;
         printf("%.3lf%%",c);
         return 0;
    }
    

    1.3.7

    描述
    对于多项式f(x) = ax^3 + bx^2 + cx + d 和给定的a, b, c, d, x,计算f(x)的值。

    #include<iostream>
    #include<cstdio>
    using namespace std;
    int main()
    {
    	double x,a,b,c,d,s;
    	cin>>x>>a>>b>>c>>d;
    	s=a*x*x*x+b*x*x+c*x+d;
    	printf("%.7lf",s);
    	return 0;
    }
    
    

    1.3.8

    描述
    利用公式 C = 5 * (F-32) / 9 (其中C表示摄氏温度,F表示华氏温度) 进行计算转化。

    #include<iostream>
    #include<cstdio>
    using namespace std;
    int main()
    {
    	double c,f;
    	scanf("%lf",&f);
    	c=5*(f-32)/9;
    	printf("%.5lf",c);
    	return 0;
    }
    

    1.3.9

    描述
    给出圆的半径,求圆的直径、周长和面积。

    #include<iostream>
    #include<cstdio>
    using namespace std;
    int main()
    {
    	double r,d,c,s;
    	const double Pi=3.14159;
    	scanf("%lf",&r);
    	d=2*r;
    	c=d*Pi;
    	s=Pi*r*r;
    	printf("%.4lf %.4lf %.4lf",d,c,s);
    	return 0;
    }
    

    1.3.10

    描述
    对于阻值为r1和r2的电阻,其并联电阻阻值公式计算如下:

    R = 1/(1/r1 + 1/r2)

    #include<iostream>
    #include<cstdio>
    using namespace std;
    int main()
    {
    	double r1,r2,R;
    	scanf("%lf%lf",&r1,&r2);
    	R=1/(1/r1+1/r2);
    	printf("%.2lf",R);
    	return 0;
    }
    
    

    1.3.11

    描述
    计算两个双精度浮点数a和b的相除的余数,a和b都是正数的。这里余数(r)的定义是:a = k * b + r,其中 k是整数, 0 <= r < b。

    #include<cstdio>
    using namespace std;
    int main()
    {
    	double a,b,r;
    	int k;
    	scanf("%lf%lf",&a,&b);
        k=a/b;
    	r=a-k*b;
    	printf("%g",r);
    	return 0;
    }
    

    1.3.12

    描述
    对于半径为r的球,其体积的计算公式为V=4/3*πr3,这里取π= 3.14。

    现给定r,求V。

    #include<cstdio>
    using namespace std;
    int main()
    {
    	double r,v;
    	scanf("%lf",&r);
        v=(double)4/3*3.14*r*r*r;
    	printf("%.2lf",v);
    	return 0;
    }
    

    1.3.13

    描述
    将一个三位数反向输出。

    #include<iostream>
    using namespace std;
    int main()
    {
    	int a;
    	cin>>a;
    	cout<<a%10<<a/10%10<<a/100;
    	return 0;
    }
    

    1.3.14

    描述
    一只大象口渴了,要喝20升水才能解渴,但现在只有一个深h厘米,底面半径为r厘米的小圆桶(h和r都是整数)。问大象至少要喝多少桶水才会解渴。

    #include<iostream>
    #include<cstdio>
    using namespace std;
    int main()
    {
    	int h,r,t;
    	double v,pi=3.14159;
    	cin>>h>>r;
    	v=h*r*r*pi/1000;
    	t=20/v+1;
    	cout<<t;
    	return 0;
    }
    

    1.3.15

    描述
    你买了一箱n个苹果,很不幸的是买完时箱子里混进了一条虫子。虫子每x小时能吃掉一个苹果,假设虫子在吃完一个苹果之前不会吃另一个,那么经过y小时你还有多少个完整的苹果?

    #include<iostream>
    #include<cstdio>
    using namespace std;
    int main()
    {
    	int n,x,y,s;
    	cin>>n>>x>>y;
    	s=n-(double)y/x;
    	cout<<s;
    	return 0;
    }
    

    1.3.16

    描述
    已知线段的两个端点的坐标A(Xa,Ya),B(Xb,Yb),求线段AB的长度。

    #include<iostream>
    #include<cstdio>
    #include<cmath>
    using namespace std;
    int main()
    {
    	double xa,ya,xb,yb,s;
    	scanf("%lf%lf%lf%lf%",&xa,&ya,&xb,&yb);
    	s=sqrt((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb));
    	printf("%.3lf",s);
    	return 0;
    }
    

    1.3.17

    描述
    平面上有一个三角形,它的三个顶点坐标分别为(x1, y1), (x2, y2), (x3, y3),那么请问这个三角形的面积是多少。

    #include<iostream>
    #include<cstdio>
    #include<cmath>
    using namespace std;
    int main()
    {
        float x1,y1,x2,y2,x3,y3;
        double a,b,c,p,s;
        scanf("%f%f%f%f%f%f",&x1,&y1,&x2,&y2,&x3,&y3);
        a=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
        b=sqrt((x1-x3)*(x1-x3)+(y1-y3)*(y1-y3));
        c=sqrt((x3-x2)*(x3-x2)+(y3-y2)*(y3-y2));
        p=(a+b+c)/2;
        s=sqrt(p*(p-a)*(p-b)*(p-c));
        printf("%.2lf",s);
    	return 0;
    }
    

    1.3.18

    描述
    给出一个等差数列的前两项a1,a2,求第n项是多少。

    #include<iostream>
    #include<cstdio>
    #include<cmath>
    using namespace std;
    int main()
    {
        int a1,a2,n,s;
        cin>>a1>>a2>>n;
        s=(a2-a1)*(n-1)+a1;
        cout<<s;
    	return 0;
    }
    

    1.3.19

    描述
    输入两个正整数A和B,求A*B。

    #include<iostream>
    #include<cstdio>
    #include<cmath>
    using namespace std;
    int main()
    {
        unsigned int a,b;
        cin>>a>>b;
        cout<<a*b;
    	return 0;
    }
    

    1.3.20

    描述
    给定非负整数n,求2^n。

    #include<iostream>
    #include<cstdio>
    #include<cmath>
    using namespace std;
    int main()
    {
        int n,a=1;
        cin>>n;
        for(int i=1;i<=n;i++)
           a=a*2;
        cout<<a;
    	return 0;
    }
    
  • 相关阅读:
    core dump的使用
    wav文件格式
    Unicode编码 【转】
    WAV格式中常见的压缩编码
    两台交换机级联端口mac地址表维护(转载)
    pthread_cond_wait()的使用方法
    makefile自动依赖[转]
    11月的第一天
    再读simpledb 之 事务管理的实现(3)
    再读simpledb 之 元数据管理(1)
  • 原文地址:https://www.cnblogs.com/axma/p/9429277.html
Copyright © 2011-2022 走看看