Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Sub Array Printer

import std.stdio;
import std.string, std.math;

int main(string[] args)
{
    string[] kume;
    
    writeln("Kümenin elemalarını giriniz: \n");
    kume = readln.chomp.split(" ");
    
    int altkume = cast(int)pow(2, kume.length);
    
    for(int i = 0; i < altkume; i++)
    {
        write("{ ");
        ulong combination = i;
        for(int j = 0; combination > 0; j++)
        {
            if(combination % 2 == 1)
            {
                write(kume[j]);
                if(combination / 2 > 0)
                    write(", ");
            }
            combination /= 2;
        }
        writeln(" }");
    }
    
	return 0;
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.