Abhishek Dwivedi
13-09-2007, 03:55 PM
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
Projjwal
13-09-2007, 07:18 PM
Programing Language- Any language
Algorithm required-VBR(Variable bit rate) for mp3
Program(if made)-LAME
Quiz_Master
14-09-2007, 02:59 AM
Programming Language : C/C++
Algorithm Required : To sort a list of names in alphabeticle order.
Projjwal
14-09-2007, 10:33 AM
^^@Quiz_Master
-----------------------------------------------------
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
/* 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 %s\n", 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
Quiz_Master
14-09-2007, 11:18 AM
Hey Projjval .. Thanks... Now I can complete my homework :D
Abhishek Dwivedi
14-09-2007, 04:09 PM
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.
Zeeshan Quireshi
14-09-2007, 08:54 PM
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!");
}
}
}
QwertyManiac
15-09-2007, 07:30 AM
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 ...
Projjwal
16-09-2007, 11:50 AM
^^
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 <directory_name> 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.
mehulved
16-09-2007, 08:44 PM
As example if i type cd <directory_name> 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.
mehulved
18-09-2007, 03:43 PM
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
Zeeshan Quireshi
18-09-2007, 07:29 PM
^^
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 <directory_name> 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 .
Projjwal
18-09-2007, 11:46 PM
Yea.....sending through system() is true. but wht about the output of the cmd
window in my application window?
Abhishek Dwivedi
30-10-2007, 07:35 PM
congrats guys...v now have a whole new programing section....cool uh?
vBulletin® v3.7.0, Copyright ©2000-2008, Jelsoft Enterprises Ltd.