Home
Top.Mail.Ru Yandeks.Metrika
Forum: "Main";
Current archive: 2002.01.08;
Download: [xml.tar.bz2];

Down

New problem: + ( Find similar branches


stalin   (2001-12-18 00:20) [0]

As knowing how many digits in a number are in a mathematical way to unfold a number (that is, it was 135, 531 should be obtained) ....... Here! ; +)



Blackweber   (2001-12-18 00:28) [1]

It is possible to start a cycle from 1 to length (num), in which the first digit is read and put at the end of the number.



Blackweber   (2001-12-18 00:34) [2]

those. 135> 351> 513



False_Delirium   (2001-12-18 01:02) [3]

Function Reverse (Z: Integer): Integer;
var T: Integer;
begin
Result: = 0;
T: = Trunc (Ln (Z) / Ln (10));
while Z> 0 do
begin
Inc (Result, (Z mod 10) * Round (Exp ((T) * Ln (10))));
Z: = Z div 10;
Dec (T);
end
end;



Sergey_n   (2001-12-18 01:37) [4]

I can offer a variant in C ++

int x = 27531; // which should be deployed
int y = 0; // where to deploy
int n = (int) log10 (x); // the length of the number to be expanded
for (int i = n; i> = 0; i -) {
y=y+((int)(x/pow(10,i))-10*(int)(x/pow(10,i+1)))*(int)pow(10,n-i);
}



False_Delirium   (2001-12-18 02:05) [5]

> Sergey_n You have 14 operations for the interration..and I have 10 ... :) .. heh ..:)) ..:))) ... who is less ..?. :)))



Sergey_n   (2001-12-18 03:16) [6]

The question was posed to write, and not who is less. In this case, the task is completed. By the way how do you think (iteration) ????



False_Delirium   (2001-12-18 04:14) [7]

Why did you then write if the task was already completed when the first example was written .. ?? The number of iterations is the number of repetitions of the cycle, and the number of operations is the number of arithmetic operations per iteration.



Sergey_n   (2001-12-18 22:59) [8]

2False_Delirium when I started writing it was not yet completed.

> The number of iterations is the number of repetitions of the cycle, and the number
> operations is the number of arithmetic operations per iteration.
it's a no brainer. Are you sure that in the interior of Fu-i Inc, Round, ... arithmetic operations as much as you think ?????



False_Delirium   (2001-12-19 00:10) [9]

Heh ..:) ... but I'm sure in Inc, but Round is validly executed in 3 operations, you can remove it altogether ..... but what do you say about pow ...:) ...? ... :)



KilkennyCat   (2001-12-19 02:27) [10]

but this is not a mathematical way.



Sergey_n   (2001-12-19 04:41) [11]

2False_Delirium I was not lazy and tested using a trace. prog
Label1-> Caption = DateTimeToStr (Now ());
double x = 20, y;
for (register __int16 i = 0; i <2767; i ++)
for (register __int16 j = 0; j <32767; j ++)
<test expression>;

Label2-> Caption = DateTimeToStr (Now ());

and here is the result:
expression | runtime (for my computer)
-----------------------------------------------------------
pow (10, x) | 19 sec
exp (x) | 28 sec
ln (x) | 25 sec
-----------------------------------------------------------

total exp + ln = 53 sec, pow + pow + pow = 57 sec
but if you add Inc, Round, Dec, .... to exp + ln
then you can still argue who is faster.



False_Delirium   (2001-12-19 05:16) [12]

Write in Pascal to start and then compare .. :)) ... to test ...
otherwise you need to consider two languages ​​in the context of execution speed .. :) ..
Yes ... so you test immediately the function of "coup" ....



False_Delirium   (2001-12-19 05:32) [13]

> KilkennyCat And what is this method .. ??.:) ... exactly mathematical, no other operations were used ..



False_Delirium   (2001-12-19 05:37) [14]

Yes, by the way ... DateTimeToStr (Now ()) is a slightly unsuitable function for such tests .. :)) ..



Sergey_n   (2001-12-19 06:10) [15]

2False_Delirium Delphi is too lazy to bet, but why do not you like DateTimeToStr (Now ())? If you are on accuracy, then increase the cycle (or their number) to last longer.



KilkennyCat   (2001-12-20 01:33) [16]

> False_Delirium Do maths have cycles? :)



Pages: 1 whole branch

Forum: "Main";
Current archive: 2002.01.08;
Download: [xml.tar.bz2];

Top









Memory: 0.86 MB
Time: 0.246 c
1-22016
Leviathan
2001-12-13 23:05
2002.01.08
Appearance form


3-21954
strahov
2001-12-05 15:32
2002.01.08
Has anyone met a bug


14-22387
- = CrazyFish = -
2001-11-09 16:28
2002.01.08
the question is not the topic


1-22085
ProfiUgl
2001-12-19 15:24
2002.01.08
How to read command line options


3-21898
Delirium
2001-11-30 18:56
2002.01.08
Is it possible to asynchronously run the stored procedure?





afrikaans albanian Arabic armenian azerbaijani basque belarusian bulgarian catalan Chinese (Simplified) Chinese (Traditional) croatian Czech danish Dutch English estonian filipino finnish French
galician georgian German greek haitian Creole hebrew Hindi hungarian icelandic indonesian Irish italian japanese Korean latvian lithuanian macedonian malay maltese norwegian
persian polish portuguese Romanian russian serbian slovak Slovenian Español swahili Swedish thai turkish Ukrainian urdu vietnamese welsh yiddish bengali bosnian
cebuano Esperanto gujarati hausa hmong igbo javanese kannada khmer lao latin maori marathi mongolian nepali punjabi somali tamil telugu yoruba
zulu
English French German Italian Portuguese Russian Spanish