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;
- prec = 3;
- Var Out: TextFile;
- Deg: Extended;
- I : QWord = 0;
- Function getDegreeName: Byte;
- Var I: low..high;
- Begin
- For I := low To High Do
- if (CompareValue(Deg, I) = EqualsValue) Then
- Exit(I);
- Exit(Floor(Deg));
- End;
- Function toString(const F: Extended): String;
- Begin
- Result := FloatToStr(F);
- if (Length(Result) < prec) and (Pos('.', Result) = 0) Then
- Result += '.0';
- While (Length(Result) <= prec) Do
- Result += '0';
- End;
- Begin
- DefaultFormatSettings.DecimalSeparator := '.';
- Writeln('-- start --');
- AssignFile(Out, 'output.txt');
- Try
- ReWrite(Out);
- Writeln(Out, '#include <iostream>');
- Writeln(Out);
- Writeln(Out, 'using namespace std;');
- Writeln(Out);
- Writeln(Out, 'char e[][10] = {"jedynka", "dwojka", "trojka", "czworka", "piatka", "szostka"};');
- Writeln(Out, '#define a(b,c) if(((b-d)<0?-b+d:b-d)<',toString(inc),')cout<<e[c-1]<<endl;');
- Writeln(Out);
- Writeln(Out, 'int main()');
- Writeln(Out, '{');
- Writeln(Out, ' double d;');
- Writeln(Out, ' cin >> d;');
- Writeln(Out);
- Deg := low;
- While (Deg <= high+inc) do
- Begin
- Write(Out, ' a(', toString(Deg), ',', getDegreeName, ') else');
- if (I mod 10 = 0) Then
- Writeln(Out);
- Deg += inc;
- I += 1;
- End;
- Writeln(Out, ' cout << "poza zakresem" << endl;');
- Writeln(Out, '}');
- Finally
- Flush(Out);
- CloseFile(Out);
- End;
- Writeln('-- done --');
- Readln;
- End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement