1011-1012-1013-1014-1015

阅读量: 264 编辑

1011-甲流疫情死亡率

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

//爱码岛编程 
#include <iostream>
using namespace std;

int main() {
  cout.flags(ios::fixed);
  cout.precision(3);

  int a, b; // 确诊数和死亡数
  cin >> a >> b;
  cout << 100.0 * b / a << "%";

  return 0;
}

1012-计算多项式的值

对于多项式f(x)=ax3+bx2+cx+d和给定的a,b,c,d,x,计算f(x)的值,保留到小数点后7位

//爱码岛编程 
#include <iostream>
using namespace std;

int main() {
  cout.flags(ios::fixed);
  cout.precision(7);

  double x, a, b, c, d;
  cin >> x >> a >> b >> c >> d;
  cout << a * x * x * x + b * x * x + c * x + d;

  return 0;
}

1013-温度表达转化

利用公式 C=5×(F−32)÷9(其中C表示摄氏温度,F表示华氏温度)进行计算转化,输入华氏温度F,输出摄氏温度C,要求精确到小数点后5位。

//爱码岛编程 
#include <iostream>
using namespace std;

int main() {
  cout.flags(ios::fixed);
  cout.precision(5);

  double f;
  cin >> f;
  cout << 5 * (f - 32) / 9.0 << endl;

  return 0;
}

1014-与圆相关的计算

给出圆的半径,求圆的直径、周长和面积。输入圆的半径实数r,输出圆的直径、周长、面积,每个数保留小数点后4位。圆周率取值为3.14159 。

//爱码岛编程 
#include <iostream>
using namespace std;

const double PI = 3.14159;

int main() {
  cout.flags(ios::fixed);
  cout.precision(4);

  double r;
  cin >> r;
  cout << 2 * r << " " << 2 * PI * r << " " << PI * r * r;

  return 0;
}

1015-计算并联电阻的阻值

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

输入两个电阻阻抗大小,浮点型。输出并联之后的阻抗大小,结果保留小数点后2位。

//爱码岛编程
#include <iostream>
using namespace std;

int main() {
  cout.flags(ios::fixed);
  cout.precision(2);

  double r1, r2;
  cin >> r1 >> r2;
  cout << 1 / ((1 / r1) + (1 / r2));
  
  return 0;
}
爱码岛编程公众号
试卷资料
爱码岛编程小程序
在线刷题
苏ICP备13052010号
©2023 南京匠成信息科技有限公司