Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <cmath>
- using namespace std;
- double theSteinhartHartformula(double);
- const int N = 2; //number of columns
- int main() {
- setlocale(LC_ALL, "Russian");
- double* resistance = new double[N];
- double* temperature = new double[N];
- //-------------enterAndCalculation-----------------
- for (int i = 0; i < N; i++) {
- cout << "Write a " << i + 1 << "th resistance: ";
- cin >> resistance[i];
- temperature[i] = theSteinhartHartformula(resistance[i]);
- }
- //-------------display-------------------
- system("CLS");
- cout << setw(6) << "R,Ом |"
- << setiosflags(ios::fixed)
- << setiosflags(ios::showpoint);
- for (int i = 0; i < N; i++) {
- cout << setprecision(3)
- << setw(9) << resistance[i] << "|";
- }
- cout << endl;
- cout << setw(6) << "t,°C |";
- for (int i = 0; i < N; i++) {
- cout << setprecision(3)
- << setw(9) << temperature[i] << "|";
- }
- delete[] resistance;
- delete[] temperature;
- return 0;
- }
- double theSteinhartHartformula(double resistance) {
- double A = 1.5524e-3;
- double B = 2.4142e-4;
- double C = 9.62e-8;
- double T, t;
- T = 1 / (A + B * log(resistance) + C * pow(log(resistance), 3));
- t = T - 273;
- return t;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement