|
|
вернуться в форумIf you are a good programer, help me Who understand the task? I mean difinition of "number": A number begins with a digit and contains only digits and possibly one point “.”, followed by one or more digits. As in the case of a string a number is the maximal by inclusion sequence of symbols that satisfies the given above requirement. I wrote a program: program Example1; var a2,a3:byte; n,t:integer; begin read(n); t:=n; a2:=0; while n mod 2 = 0 do begin n:=n div 2; inc(a2); end; a3:=0; while n mod 3 = 0 do begin n:=n div 3; inc(a3); end; write(n,'=2^',a2,'*3^',a3,'*',n); {this program writes a number in n=(2^k)*(3^l)*m form} {10=2^1*3^0*5} {36=2^2*3^2*1} end. Could you write HTML-answer? Re: If you are a good programer, help me Послано JTim 26 июн 2008 22:46 <span class=keyword>program</span> Example1; <span class=keyword>var</span> a2,a3:byte; n,t:integer; <span class=keyword>begin</span> read(n); t:=n; a2:=<span class=number>0</span>; <span class=keyword>while</span> n <span class=keyword>mod</span> <span class=number>2</span> = <span class=number>0</span> <span class=keyword>do</span> <span class=keyword>begin</span> n:=n <span class=keyword>div</span> <span class=number>2</span>; inc(a2); <span class=keyword>end</span>; a3:=<span class=number>0</span>; <span class=keyword>while</span> n <span class=keyword>mod</span> <span class=number>3</span> = <span class=number>0</span> <span class=keyword>do</span> <span class=keyword>begin</span> n:=n <span class=keyword>div</span> <span class=number>3</span>; inc(a3); <span class=keyword>end</span>; write(n,<span class=string>'=2^'</span>,a2,<span class=string>'*3^'</span>,a3,<span class=string>'*'</span>,n); <span class=comment>{this program writes a number in n=(2^k)*(3^l)*m form}</span> <span class=comment>{10=2^1*3^0*5}</span> <span class=comment>{36=2^2*3^2*1}</span> <span class=keyword>end</span>. |
|
|