Posted in Non Tech

Internet of Facts

Recently I received several fake fact messages, and what was more interesting is the people forwarding these messages were highly educated. Today it is not uncommon to receive messages that say If we do not forward it then a decade of bad luck, or we wont ever live happily, or maybe even we’d get murdered that midnight itself by a ghost. After some thought, I realised that such things were extremely uncommon before the advent of the internet. Before the Internet existed, people relied on written sources of information. They used to read newspapers for information. Books and journals were published to demonstrate a point. These used to take effort and time to make, and rarely contained false information, because hardly anyone would take so much pain and effort to spread false messages. Continue reading “Internet of Facts”

Advertisements
Posted in Non Tech

Wireless World – A wonder

A long time back, when phones, were introduced, they had a manual pad and pre-programmed functions which limited their usage (only calling). At that time we didn’t even considered that making a phone controllable, and that too with a touch would be possible (and even if possible, then not feasible). Today we use smartphones and hardly see any of the primitive, only calling design phones, and control them by a touch.

Continue reading “Wireless World – A wonder”

Posted in Non Tech

QR Codes – Omnipresent

I am amused at how the world has been revolutionized by technology. Recently in my nearby supermarket, I saw a simple placard having a QR code powered by something called Paytm (it’s an acronym of Pay Through Mobile). This placard, was not only in that shop, I could see it on the cabs, petrol pumps and even in the parkings at a few places. The technology that this little placard uses is the QR code. What is more ironical is that this QR code was used by Japanese automobile companies to identify their machine parts, and now these codes are used for identifying humans – yes, you will find this code on the visiting Cards of people and even on their T-Shirts. Continue reading “QR Codes – Omnipresent”

Posted in Non Tech

Rains – Boon or Catastrophe

A few days ago on a fine evening, while returning to my home from my institute on my two wheeler, suddenly it started raining heavily. I did have my raincoat and a bag cover for my rescue, but yet the downpour was heavy enough to drench me through the neck opening alone. Such a heavy rain and that too just after it had rained in the morning flooded all the roads, and soon the roads transformed into pools. I was wondering that these heavy rains must be a chaos for the people. In some way I was wrong.

Continue reading “Rains – Boon or Catastrophe”

Posted in C++

ZCO 2013 – Solution : Tournament

The problem statement is described here.

The first impulse would be to calculate all the match revenues and then sum up… but it would be O(n^2) which isn’t good enough for the second subtask.

The key to the problem lies in an observation. Let’s consider an examples and then generalise it.

Let us take a different example than the given sample case.

4

3 10 7 5

Now the revenues for each match are :

10-5 +10-7 + 10-3 + 7-5 + 7-3 + 5-3 = 23

but wait that’s not what we will do… Look at it in the following manner :

Continue reading “ZCO 2013 – Solution : Tournament”

Posted in C++

Making a User friendly menu in old compilers for c++

This post is specially for those poor students who still have to use older compilers (Like Turbo C++). What I really mean by saying old is that a compiler supporting <CONIO.H > . This is no standard header file (and there is a specific reason to it too) but helps in creating Better interface for the USER.

What do we actually do to create a graphical interface ? We create colored illusions which make it seem that the interface is interactive. The top commands for this work are :

void textbackground(int );

void textcolor(int);

void gotoxy(int,int);

void clrscr(void);

char& getch(void);

Now to the working :

What happens when we have a menu and we want the current item to look like it’s selected, the special emphasis is brought about by a different color. Same thing we will also do here. Now a bit of coding manipulations :

Code for making a menu (without graphic interface) :

char* menu_items[] = {"Item 1","Item 2","Item 3"};   //Change these as per requirement
int n=3; // This variable stores the number of menu items we have
for(int i=0;i<n;i++)

{
     cout  <<   i+1   <<  " "  ;
     puts(menu_items[i]);
}                //Insert some command for pausing if required

This loop will display all our menu items along with their serial number.
Now a simple example on using the coloring commands
The output is like this :-

Plain menu
Plain menu without any graphical interface

Now the basic trick is to detect what button the user has pressed. To do this we will use the getch() command. {Note that getch() can appear on the right side of an expression and also as a normal function call}. The getch() command returns us the ascii value of the key we have hit. The tricky part here is that when the user presses an arrow key, the ascii value returned is not just one but two, So we need not only one getch() but two of them.

Continue reading “Making a User friendly menu in old compilers for c++”