Új hozzászólás Aktív témák
-
pmonitor
aktív tag
válasz
joysefke #9468 üzenetére
Én így fordítottam át:
using System;
namespace IsmPerm
{
class Program
{
static int findCeilInt(int[] str, int first, int l, int h)
{
int ceilIndex = l;
for (int i = l + 1; i <= h; i++)
if (str[i] > first && str[i] < str[ceilIndex])
ceilIndex = i;
return ceilIndex;
}
static void Teszt_1(int[] tomb)
{ //https://www.geeksforgeeks.org/print-all-permutations-of-a-string-with-duplicates-allowed-in-input-string/
int size = tomb.Length;
Array.Sort(tomb);
bool isFinished = false;
while (!isFinished)
{
int x = 1, i;
for (int k = 0; k < size; ++k) Console.Write("{0} ", tomb[k]);
Console.WriteLine("");
for (i = size - 2; i >= 0; --i) if (tomb[i] < tomb[i + 1]) break;
if (i == -1) isFinished = true;
else
{
int ceilIndex = findCeilInt(tomb, tomb[i], i + 1, size - 1);
int temp = tomb[i];
tomb[i] = tomb[ceilIndex];
tomb[ceilIndex] = temp;
Array.Sort(tomb, i + 1, size - i - 1);
}
}
}
static void Main(string[] args)
{
int[] tomb = new int[] { 500, 500, 600, 600, 700};
Teszt_1(tomb);
Console.ReadKey();
}
}
}
Új hozzászólás Aktív témák
● ha kódot szúrsz be, használd a PROGRAMKÓD formázási funkciót!
- 24 GB-os RTX 6000 HP - garanciával
- Telefon felvásárlás!! Samsung Galaxy A14/Samsung Galaxy A34/Samsung Galaxy A54
- Intel Processzorok sok db : Xeon E5-1620V3, Pentium G4400T, i3 6100, i3-4130, i3-2140T
- Bomba ár! Dell Latitude E5410 - i5-520M I 4GB I 250GB I DVDRW I 14,1" WXGA I W10 I Gari!
- ÁRGARANCIA!Épített KomPhone i5 14400F 32/64GB RAM RX 9060 XT 16GB GAMER PC termékbeszámítással
Állásajánlatok
Cég: FOTC
Város: Budapest