Thursday, August 26, 2010

LinkLists in C++: Part 4

Fourth in the series of Link-List funtions.

/***************************************************/
#include< iostream.h >
#include< conio.h >
#include< stdlib.h >

struct node
{
int info;
node* next;
}*start, *end, *t;

void reverse()
{
int n;
t = start;
while(t != NULL)
{
n++;
t = t->next;
}
for(int i = 0;i <= n-3;i++)
{
t = start;
while(t->next->next->next != NULL)
t = t->next;
t->next->next->next = t->next;
t->next->next = NULL;
}
t = start;
t->next->next = start;
t->next = NULL;
t1 = start;
start = end;
end = t1;
}

void sort()
{
t = start;
while(t != NULL)
{
t1 = start;
while(t1 != NULL)
{
if(t1->next->info > t1->next->next->info)
{
t1->next = t1->next->next;
t1->next->next = t1->next->next->next;
t1->next->next->next = t1->next;
}
t1 = t1->next;
}
t = t->next
}
}

LinkLists in C++: Part 3

Third in the series of Link-List funtions.

/***************************************************/
#include< iostream.h >
#include< conio.h >
#include< stdlib.h >

struct node
{
int info;
node* next;
}*start, *end, *t;


void listnode()
{
t = start;
cout <<"\nTHE CONTENTS ARE\n";
while(t != NULL)
{
cout <info <
t = t->next;
}
}

void count()
{
t = start;
int ctr = 0;
while(t != NULL)
{
ctr++;
t = t->next;
}
cout <<"\nNUMBER OF NODES ARE" <
}

void search()
{
t = start;
int n, flag = 0;
cout <<"\nENTER INFO TO BE SEARCHED ::";
cin >>n;
while(t!= NULL)
{
if(t->info == n)
{
flag = 1;
break;
}
}
if(flag == 0)
cout <<"\nNOT FOUND";
else
cout <<"\nFOUND";
}

LinkLists in C++: Part 2

Second in the series of Link-List funtions.

/***************************************************/
#include< iostream.h >
#include< conio.h >
#include< stdlib.h >

struct node
{
int info;
node* next;
}*start, *end, *t;



void delnode()
{
int ch;
cout <<"\n1.DELETE IN THE BEGINNING.";
cout <<"\n2.DELETE AT THE END.";
cout <<"\n3.DELETE IN THE MIDDLE.";
cout <<"\nENTER CHOICE";
cin >> ch;
switch(ch)
{
case 1:delbeg();
break;
case 2:delend();
break;
case 3:delmid();
break;
default:cout <<"\nWRONG CHOICE";
}
}

void delbeg()
{
t = start->next;
start->next = NULL;
delete start;
start = t;
}

void delend()
{
t = start;
while(t->next->next != NULL)
t=t->next;
t->next = NULL;
delete end;
end = t;
}

void delmid()
{
int n;
cout <<"\nENTER THE INFO TO BE DELETED";
cin >>n;
t = start;
while(t != NULL)
{
if(t->next->info == n)
{
t1 = t->next;
t->next = t1->next;
t1->next = NULL;
delete t1;
break;
}
t = t->next;
}
}

LinkLists in C++: Part 1



First in the series of Link-List funtions.

/***************************************************/
#include< iostream.h >
#include< conio.h >
#include< stdlib.h >

struct node
{
int info;
node* next;
}*start, *end, *t;

void addnode()
{
int ch;
if(start == NULL)
{
start = new node;
if(start == NULL)
{
cout <<"\nNOT ENOUGH MEMORY";
getch();
exit(0);
}
cout <<"\nENTER INFO";
cin >>start->info;
start->next = NULL;
end = start;
}
else
{
cout <<"\n1.ADD IN THE BEGINNING.";
cout <<"\n2.ADD AT THE END.";
cout <<"\n3.ADD IN THE MIDDLE.";
cout <<"\n4.EXIT.";
cout <<"\n\nENTER CHOICE ::";
cin >> ch;
switch(ch)
{
case 1:addbeg();
break;
case 2:addend();
break;
case 3:addmid();
break;
case 4:exit(0);
break;
default:cout <<"WRONG CHOICE.";
}
}
}

void addbeg()
{
t = new node;
if(t == NULL)
{
cout <<"\nNOT ENOUGH MEMORY";
getch();
exit(0);
}
cout <<"\nENTER INFO :: ";
cin >>t->info;
t->next = start;
start = t;
}

void addend()
{
t = new node;
if(t == NULL)
{
cout <<"\nNOT ENOUGH MEMORY";
getch();
exit(0);
}
cout <<"\nENTER INFO :: ";
cin >>t->info;
t->next = NULL;
end->next = t;
end = t;

}

void addmid()
{
int ch;
cout <<"\n1.ADD BEFORE A GIVEN NODE.";
cout <<"\n2.ADD AFTER A GIVEN NODE.";
cout <<"\nENTER CHOICE :: ";
cin >> ch;
switch(ch)
{
case 1:addbefore();
break;
case 2:addafter();
break;
default:cout <<"\nWRONG CHOICE";
}
}

void addbefore()
{
int n;
cout <<"\nENTER THE NODE INFO.";
cin >>n;
t = start;
while(t != NULL)
{
if(t->next->info == n)
{
t1 = new node;
if(t1 == NULL)
{
cout<<"\nNOT ENOUGH MEMORY";
getch();
exit(0);
}
cout <<"\nENTER INFO";
cin >>t1->info;
t1->next = t->next;
t->next = t1;
}
t = t->next;
}
}

void addafter()
{
int n;
cout <<"\nENTER THE NODE INFO.";
cin >>n;
t = start;
while(t != NULL)
{
if(t->info == n)
{
t1 = new node;
if(t1 == NULL)
{
cout<<"\nNOT ENOUGH MEMORY";
getch();
exit(0);
}
cout <<"\nENTER INFO";
cin >>t1->info;
t1->next = t->next;
t->next = t1;
}
t = t->next;
}
}

Sunday, August 22, 2010

A Nifty Trick...

A trick is to make any PC shut down in a specified time with a horrifying message. No harm will be done of course. We will just make a small executable of ".exe" format for our mischief.
The executable will work its magic only when clicked, so expect no "virus-action", but it can be easily disguised as some other program. 
Here are the steps:
  1. On your Desktop, Right click->New->Shortcut
  2. Dialog Box appears, type in: shutdown -s -t 20 -c "YOUR MESSAGE"
  3. Now click on Next.
  4. Shortcut Name is asked, call it "shutdown.exe"
  5. Click on finish.
    shutdown.exe will be created on the desktop.
Note that the file I created has a string argument "YOUR MESSAGE", which can be replaced by anything. example: "FATAL ERROR: SYSTEM CRASH REPORTED". Also, the final output will look somewhat like this on your desktop, Ive shown the portion the the Taskbar that displays the message. The value 20 is the time delay in seconds.

The coolest part is that Alt+F4 or Task manager cannot terminate this file!!!
To terminate: Start->Run->"shutdown -a" and press enter. Moreover this file is easily deletable.

Now for a finishing touch:

  1. Rename the executable to a commonly used program, example: My computer
  2. Right Click->Properties->Shortcut Tab->Change Icon
  3. Now the Icon image must be chosen according to the name given, here it is My computer

Apply any standard icon image and name to your file, send it to friends or have them click it on your PC and watch their faces.

Friday, August 13, 2010

Microsoft Robotics Developer Studio

Robotics Developer Studio, or RDS, is an environment made by Microsoft to develop and test projects on robotics. This is a major step by Microsoft indeed, to promote hobbyists as well as professional developers. Using this Windows-based suite, not only can we write code for a robot, but simulate a virtual prototype in a real world scenario using the state-of-the-art simulation engine. Whats looks so unique about this software is the fact that the RDS has not been built with the expert in mind, rather a beginner. Technically speaking, the learning curve is smooth and provides ample opportunities for experimentation.

Programmers can choose between the the familiar Visual studio and Visual Programming Language or VPL. VPL can be called a beginner's programming platform with a simple drag 'n' drop interface through which we can generate C# code. So you can understand how easy it is to code for an application using RDS.

The most important feature in this studio is the simulation. Now all of us must have seen the port-based emulation feature of IDE's like KEIL, etc. RDS goes way beyond testing with its 3-D simulation software. Not that there is a parallel here, but it definitely shows how far Microsoft has taken the concept of simulation. RDS allows us to directly test the behavior of our robot in a physics-based virtual world. Not only our software, but also the feasibility of the concept can be checked by testing it against a variety of environments.

Microsoft has provided several tutorials for getting a good start on their product. Besides this, external help has also been provided by software developers all over the world and their programs are just a few clicks away.

A let-down for the average Indian student is, however the requirements. The RDS does require a decent configuration of a PC in order to work its magic. Well this is mainly due to the Graphics requirements and overall PC specs that people normally don't think about when buying PC's. This problem can be solved easily with some minor and cheap upgrades.
The software in itself is completely free, and easily available from the Microsoft website. However you may be required to download and install additional software or drivers if you do not already have them, which is highly unlikely if you are a developer.

Overall, this amazing software by Microsoft is bound to raise eyebrows and most importantly, raise standards. It will get a thumb's up from all types of users, whether commercial or not, simply because of its quality and easy-to-use features.