C++: change the cursor for one button only
Thursday, January 10th, 2008// handle WM_SETCURSOR in button class
BOOL CMyButton::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT msg)
{
::SetCursor(m_hMyCursor);
return TRUE;
}
Recursive quicksort
Thursday, March 1st, 2007#include<stdio.h>
#include<conio.h>
void qsort(int a[],int,int);
void partition(int a[],int,int,int *);
void print(int *,int);
void swap(int *,int *);
void main()
{
int a[30],i,n;
flushall();
clrscr();
printf(”
enter how many data u want :”);
scanf(”%d”,&n);
printf(”
enter the data :”);
for(i=0;i<n;i++)
{
printf(”
%d .”,i);
scanf(”%d”,&a[i]);
}
qsort(a,0,n-1);
printf(”
SORTED DATA:
“);
print(a,n-1);
getch();
}
void qsort(int a[],int lb,int ub)
{
int j;
if(ub>lb)
{
partition(a,lb,ub,&j);
[...]
Bucket sort in C++
Tuesday, March 28th, 2006/*Bucket sort */
#include<stdio.h>
#include<conio.h>
/*Defining the strcuture for each node in the list*/
typedef struct node
{
float value;
struct node *link;
} node;
void main()
{
/*An array of structures,pointers to the structure*/
node counter[10], *n2,*n1;
float ar[10] = {0.79,0.13,0.16,0.64,0.39,0.20,0.89,0.53,0.71,0.42};
float fa[10],temp;
int i,j,k=0;
float n,a;
clrscr();
/*Initializing the elements of the counter arrray to zero*/
for(i=0;i<10;i++)
{
counter[i].value = 0;
counter[i].link = 0;
}
/*Redcuing the value equal to index of an array*/
for(i=0;i<10;i++)
{
n = ar[i];
j = [...]
Rev function and comma-separated output
Thursday, February 2nd, 2006Here is the shell command snippet to display comma-separated output:
ls -lrt | rev | sed ’s/\\([0-9][0-9][0-9]\\)/\\1,/g’ | rev | sed ’s/\\([\^0-9]\\),\\([0-9]\\)/\\1\\2/g;s/\^,\\([0-9]\\)/\\1/g’
Example:
-rw-r—– 1 sybase dba 1,572,872,192 Feb 2 07:09 master.dbf
Rev function (absent on SunOS) :
(Warning! Avoid spaces before #define - SunOS cc compiler doesn’t like them)
#include <stdio.h>
#ident "@(#)rev 1.0 [...]
Mouse handling with DOS functions in C++
Wednesday, January 25th, 2006#include<iostream.h>
#include<conio.h>
#include<dos.h>
#include<process.h>
void main()
{
clrscr();_setcursortype(_NOCURSOR);
REGS regs;
//Initializing and showing mouse
regs.x.ax=0;int86(0×33,®s,®s);
regs.x.ax=1;int86(0×33,®s,®s);
//Reading mouse click
for( ; ; )
{
//Updating mouse motions
regs.x.ax=3;int86(0×33,®s,®s);
//Reading mouse click
if(regs.x.bx==1)
{
gotoxy(2,2);textbackground(1);textcolor(15);
cprintf(”;Left Button Clicked!”;);
delay(100);
}
if(regs.x.bx==2)
{
gotoxy(2,2);textcolor(15);textbackground(1);
cprintf(”;Right Button Clicked!”;);
delay(100);
}
gotoxy(1,2);textbackground(1);cprintf(”; [...]