|
|
Регистрация Восстановить пароль |
Повторная активизация e-mail |
Регистрация | Задать вопрос |
Заплачу за решение |
Новые сообщения |
Сообщения за день |
Расширенный поиск |
Правила |
Всё прочитано |
|
Опции темы | Поиск в этой теме |
29.04.2016, 10:12 | #1 |
Новичок
Джуниор
Регистрация: 29.04.2016
Сообщений: 1
|
Помогите перевести с delphi на с++
FUNCTION IsFloatBIN(ch:char; st:string):char;
BEGIN IsFloatBIN:=chr(0); if (ch>='0')and(ch<='1') // цифры or(ch=#13)or(ch=#8) then IsFloatBIN:=ch; case ch of ',': if (Pos(',',st) = 0)and(st[Length(st)]>='0') then IsFloatBIN:=ch; end; END; PROCEDURE TForm1.DEC_to_P(const st:string;p:byte;Sender: TObject); var ost,tmp,tmp2,b:string; d:longint; e,c:integer; BEGIN if pos(',',st)=0 then begin d:=strtoint(st); ost:=''; end else begin d:=strtoint(copy(st,1,pos(',',st)-1)); ost:=copy(st,pos(',',st)+1,length(s t)-pos(',',st)); end; memo1.Lines.Clear; memo1.Lines.Add(' ПЕРЕВОД ЧИСЛА '+edit1.Text+#13#10+'ИЗ 10-ой В '+inttostr(p)+'-ую СИСТЕМУ СЧИСЕНИЯ'); memo1.Lines.Add(''); if ost<>'' then memo1.Lines.Add('----------Переводим целую часть числа----------------'); memo1.Lines.Add(''); memo1.Lines.Add('Делим число '+inttostr(d)+' на основание системы счисления = '+inttostr(p)+':'); memo1.Lines.Add(''); i:=0; repeat inc(i); e:=d mod p; if e<=9 then str(e,tmp) else case e of 10:tmp:='A'; 11:tmp:='B'; 12:tmp:='C'; 13:tmp:='D'; 14:tmp:='E'; 15:tmp:='F'; end; if e<=9 then tmp2:='' else tmp2:=' заменяем на '+tmp; memo1.Lines.Add(inttostr(d)+' / '+inttostr(p)+' = '+inttostr(d div p)+ #13#10+' остаток '+inttostr(e)+tmp2); memo1.Lines.Add(''); b:=b+tmp; c:=d; d:=d div p; until d<p; if d<=9 then str(d,tmp) else case d of 10:tmp:='A'; 11:tmp:='B'; 12:tmp:='C'; 13:tmp:='D'; 14:tmp:='E'; 15:tmp:='F'; end; b:=b+tmp; if d<=9 then tmp2:='' else tmp2:=' заменяем на '+tmp; memo1.Lines.Add('Дальше делить нельзя, поэтому собираем все остатки, начиная с конца, и '+ 'учитываем конечный результат от деления т.е. '+inttostr(c)+' / '+inttostr(p)+' = '+ inttostr(c div p)+tmp2); memo1.Lines.Add(''); tmp:=''; for i:=length(b) downto 1 do tmp:=tmp+b[i]; memo1.Lines.Add('Получим число: '+tmp); if ost<>'' then begin tmp:=tmp+','+DEC_to_P0(ost,p,Sender ); memo1.Lines.Add('Все число = '+tmp); end; Edit2.Text:=tmp; END; |
Опции темы | Поиск в этой теме |
Похожие темы | ||||
Тема | Автор | Раздел | Ответов | Последнее сообщение |
Помогите перевести c# на delphi | Mik92 | Общие вопросы Delphi | 2 | 18.12.2014 23:08 |
Помогите перевести с C++ на Delphi | Gerzs | Общие вопросы Delphi | 3 | 16.10.2009 02:20 |