📄 8iv.cpp
字号:
// roottbl.cpp Display a table of square roots for a list of
// input values from the disk file "a:values.dat"
#include <iostream.h>
#include <fstream.h>
#include <math.h>
const int PRECISION = 4; // output precision
const int WIDTH1 = 10; // width of values column
const int WIDTH2 = 15; // width of root column
void main ()
{ float value, root;
ifstream infile ("values.dat", ios::in);
cout << " value square root" << endl;
cout.precision(PRECISION); // set precision
while (infile >> value) // loop through file values...
{ root = sqrt (value);
cout.width(WIDTH1); // input values use these cols
cout << value;
cout.width(WIDTH2); // roots use next WIDTH2 cols
cout << root << endl;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -