Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Uses SysUtils, Math;
- Const low = 1;
- high = 6;
- inc = 0.01;
- Var Out: TextFile;
- Deg: Extended;
- Function getDegreeName: String;
- Const Tab: Array[low..high] of String = ('jedynka', 'dwojka', 'trojka', 'czworka', 'piatka', 'szostka');
- Var I: low..high;
- Begin
- For I := low To High Do
- if (CompareValue(Deg, I) = EqualsValue) Then
- Exit(Tab[I]);
- Exit(Tab[Floor(Deg)]);
- End;
- Begin
- DefaultFormatSettings.DecimalSeparator := '.';
- Writeln('-- start --');
- AssignFile(Out, 'output.txt');
- Try
- ReWrite(Out);
- Writeln(Out, '#include <iostream>');
- Writeln(Out, '#include <cmath>');
- Writeln(Out);
- Writeln(Out, 'using namespace std;');
- Writeln(Out);
- Writeln(Out, '#define EPSILON 0.00001');
- Writeln(Out);
- Writeln(Out, 'bool float_equal(double a, double b)');
- Writeln(Out, '{');
- Writeln(Out, ' return fabs(a-b) < EPSILON;');
- Writeln(Out, '}');
- Writeln(Out);
- Writeln(Out, 'int main()');
- Writeln(Out, '{');
- Writeln(Out, ' double degree;');
- Writeln(Out, ' cin >> degree;');
- Writeln(Out);
- Deg := low;
- While (Deg <= high+inc) do
- Begin
- Writeln(Out, ' if (float_equal(degree, ', FloatToStr(Deg), '))');
- Writeln(Out, ' cout << "', getDegreeName, '" << endl; else');
- Deg += inc;
- End;
- Writeln(Out, ' cout << "spoza zakresu" << endl;');
- Writeln(Out, '}');
- Finally
- Flush(Out);
- CloseFile(Out);
- End;
- Writeln('-- done --');
- Readln;
- End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement