我的第一次编程

来源:互联网 发布:医疗大数据是什么意思 编辑:程序博客网 时间:2024/05/22 09:22
1.average:#include<iostream>
using namespace std;
int main() {
double a, b, c;
cout << "请输入第一个数" << endl;
cin >> a;
cout << "请输入第二个数" << endl;
cin >> b;
cout << "请输入第三个数" << endl;
cin >> c;
cout.precision(3);
cout << fixed;
cout << "平均值是" << endl;
cout << (a + b + c) / 3;
system("pause");
return 0;
}
2.temperature:#include<iostream>
using namespace std;
int main() {
double f, c;
cout << "请输入华氏温度" <<endl;
cin >> f;
c = 5*(f - 32) / 9;
cout.precision(3);
cout << fixed;
cout << "摄氏温度为" << c << endl;
system("pause");
return 0;
}