Tema: Re: algoritmas
Autorius: Bamba
Data: 2009-02-26 12:09:45
1-19


1 - 4
5 - 8
9 - 11
12 - 15
16 - 19

kazkas ne taip vistiek :)

"Nerijus T" <news@upe.lt> wrote in message 
news:go5p78$9rt$1@trimpas.omnitel.net...
> #!/usr/bin/perl
> $n1 = 1;
> $n2 = 7;
> $zing=5;
> $inter=(($n2-$n1+1)/$zing);
> for ($i=$n1;$i<=$n2;$i=$i+$inter) {
> $pirm=int($i+0.5);
> $sek=int($i+$inter+0.5)-1;
> if ($sek > $n2) {$sek=$n2;}
> print "$pirm - $sek\n";
> }
>
> 1 - 1
> 2 - 3
> 4 - 4
> 5 - 6
> 7 - 7
> taip netinka
> "Bamba" <none@nonde.none> wrote in message 
> news:go5nhv$6og$1@trimpas.omnitel.net...
>> matai ner taip paprasta kaip atrodo :)
>>
>> grupiu negali but daugiau nei $zing (5).
>>
>> yra dar variantai kaip 1-7
>>
>> tai turetu pasiskirtyti taip:
>>
>> 1-2
>> 3-4
>> 5-5
>> 6-6
>> 7-7
>>
>> "Nerijus T" <news@upe.lt> wrote in message 
>> news:go5mqs$5b3$1@trimpas.omnitel.net...
>>> #!/usr/bin/perl
>>> $n1 = 1;
>>> $n2 = 19;
>>> $zing=5;
>>> print $a;
>>> $liek=($n2-$n1+1)%$zing;
>>> $p=0;
>>> if ($liek<=>0) {$p=1};
>>> $inter=int(($n2-$n1+1)/($zing-$p));
>>> for ($i=$n1;$i<=$n2;$i=$i+$inter) {
>>> $sek=$i+$inter-1;
>>> if ($sek > $n2) {$sek=$n2;}
>>> print "$i - $sek\n";
>>> }
>>>
>>>
>>> "Nerijus T" <news@upe.lt> wrote in message 
>>> news:go5l8n$29h$1@trimpas.omnitel.net...
>>>> zingsniui paskaiciuoti galima naudoti sveiko skaiciaus be apvalinimo 
>>>> iskirimo funkcija int
>>>> toliau mastyk pats
>>>> "Bamba" <none@nonde.none> wrote in message 
>>>> news:go5imt$t3h$1@trimpas.omnitel.net...
>>>>> Sveiki,
>>>>>
>>>>> situacija tokia:
>>>>>
>>>>> yra diapazonas sakykim nuo 1-19.
>>>>>
>>>>> Reikia kokio neskausmingo budo sita diapazonas padalinti i pvz 5 
>>>>> grupes.
>>>>>
>>>>>
>>>>> 1-4
>>>>> 5-8
>>>>> 9-12
>>>>> 13-16
>>>>> 17-19
>>>>>
>>>>>
>>>>> pvz 1-9
>>>>>
>>>>> 1-2
>>>>> 3-4
>>>>> 5-6
>>>>> 7-8
>>>>> 9-9
>>>>>
>>>>> Gal kas turit kokiu ideju?
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
>