The Algorithms thread

Filed Under mercialleasing.com |

  • This thread is for sharing and asking the basic Algorithms related to any Programing language.

    Way of Asking:

    Programing Language-
    Algorithm required-
    Program(if made)-
    Other Information(if required)-


    Important: Users Asking for the Algorithms should try Google search first before posting.

    Hope this will help a lot of Young Students and others who are learning the programing methodology


  • congrats guys...v now have a whole new programing section....cool uh?


  • Hey Projjval .. Thanks... Now I can complete my homework :D


  • As example if i type cd in that application it automatically create a directory with the name just like cmd.
    I did it in VB6 but that logic not applied on c or c++ pls help.
    I know that vim can do similar sort of thing, atleast on *nix. So, maybe you can check out the win32 port of vim if it has something similar and if it can help you.


  • Programming Language : C/C++
    Algorithm Required : To sort a list of names in alphabeticle order.


  • ^^@Quiz_Master
    -----------------------------------------------------
    #include
    #include
    #include

    /* Define an array of critters to sort. */

    struct critter
    {
    const char *name;
    const char *species;
    };

    struct critter muppets =
    {
    {"Kermit", "frog"},
    {"Piggy", "pig"},
    {"Gonzo", "whatever"},
    {"Fozzie", "bear"},
    {"Sam", "eagle"},
    {"Robin", "frog"},
    {"Animal", "animal"},
    {"Camilla", "chicken"},
    {"Sweetums", "monster"},
    {"Dr. Strangepork", "pig"},
    {"Link Hogthrob", "pig"},
    {"Zoot", "human"},
    {"Dr. Bunsen Honeydew", "human"},
    {"Beaker", "human"},
    {"Swedish Chef", "human"}
    };

    int count = sizeof (muppets) / sizeof (struct critter);



    /* This is the comparison function used for sorting and searching. */

    int
    critter_cmp (const struct critter *c1, const struct critter *c2)
    {
    return strcmp (c1->name, c2->name);
    }


    /* Print information about a critter. */

    void
    print_critter (const struct critter *c)
    {
    printf ("%s, the %sn", c->name, c->species);
    }


    /* Do the lookup into the sorted array. */

    void
    find_critter (const char *name)
    {
    struct critter target, *result;
    target.name = name;
    result = bsearch (&target, muppets, count, sizeof (struct critter),
    critter_cmp);
    if (result)
    print_critter (result);
    else
    printf ("Couldn't find %s.n", name);
    }

    /* Main program. */

    int
    main (void)
    {
    int i;

    for (i = 0; i < count; i++)
    print_critter (&muppets[i]);
    printf ("n");

    qsort (muppets, count, sizeof (struct critter), critter_cmp);

    for (i = 0; i < count; i++)
    print_critter (&muppets[i]);
    printf ("n");

    find_critter ("Kermit");
    find_critter ("Gonzo");
    find_critter ("Janice");

    return 0;
    }
    ---------------------------------------
    The output from this program looks like:
    ---------------------------------------
    Kermit, the frog
    Piggy, the pig
    Gonzo, the whatever
    Fozzie, the bear
    Sam, the eagle
    Robin, the frog
    Animal, the animal
    Camilla, the chicken
    Sweetums, the monster
    Dr. Strangepork, the pig
    Link Hogthrob, the pig
    Zoot, the human
    Dr. Bunsen Honeydew, the human
    Beaker, the human
    Swedish Chef, the human

    Animal, the animal
    Beaker, the human
    Camilla, the chicken
    Dr. Bunsen Honeydew, the human
    Dr. Strangepork, the pig
    Fozzie, the bear
    Gonzo, the whatever
    Kermit, the frog
    Link Hogthrob, the pig
    Piggy, the pig
    Robin, the frog
    Sam, the eagle
    Swedish Chef, the human
    Sweetums, the monster
    Zoot, the human

    Kermit, the frog
    Gonzo, the whatever
    Couldn't find Janice.
    ------------------------------------------
    Source:http://www.gnu.org/software/libc/manual/html_node/Search_002fSort-Example.html


  • Programing Language- Any language
    Algorithm required-VBR(Variable bit rate) for mp3
    Program(if made)-LAME
    Wont running LAME with the parameter -v do it? You can resample the bitrate to 64, 128 etc along too. Or did I not understand what you were asking ...


  • Yea.....sending through system() is true. but wht about the output of the cmd
    window in my application window?


  • vim is a text editor. Check the source code of win32 port of vim, you might be able to find what you need. See http://www.vim.org/download.php#pc


  • Programing Language- Any language
    Algorithm required-VBR(Variable bit rate) for mp3
    Program(if made)-LAME


  • ^^ pls explain it ..


  • ^^
    Yea I want a programming code in any language which convert normal mp3 to VBR mp3 just like LAME's -v option.
    In other word de algo to convert normal mp3 to VBR mp3.

    ----------------------------------------------
    Programing Language-C,C++
    Algorithm required-A program which support all the command of cmd
    Program(if made)-I want to access all the command of cmd throug my application
    As example if i type cd in that application it automatically create a directory with the name just like cmd.
    I did it in VB6 but that logic not applied on c or c++ pls help.


  • ^^
    Yea I want a programming code in any language which convert normal mp3 to VBR mp3 just like LAME's -v option.
    In other word de algo to convert normal mp3 to VBR mp3.

    ----------------------------------------------
    Programing Language-C,C++
    Algorithm required-A program which support all the command of cmd
    Program(if made)-I want to access all the command of cmd throug my application
    As example if i type cd in that application it automatically create a directory with the name just like cmd.
    I did it in VB6 but that logic not applied on c or c++ pls help.
    well u can do this simply by taking the input as a string and then passing the command onto the system using the system() function .


  • Programming Language: C# / .NET 3.0 / Vista

    What it Does : Outputs a String as A Voice Message

    using System;
    using System.Speech.Synthesis;

    namespace HelloSpeechSynthesis
    {
    class Program
    {
    static void Main(string args)
    {
    SpeechSynthesizer synth = new SpeechSynthesizer();
    synth.SpeakText("Hello, world!");
    }
    }
    }


  • Programing Language : C++
    Algorithms Required: A program to corupt the HDD
    Other Information: I've heard its a 3 line program that can destroy the HDD.







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about The Algorithms thread , Please add it free.

    Comments