loading...
مرجع مهندسی نرم افزار
آخرین ارسال های انجمن
حامد شیرزاد بازدید : 545 شنبه 28 آبان 1390 نظرات (0)
Mouse Management functions
 
 
#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(0x33,®s,®s);
     regs.x.ax=1;int86(0x33,®s,®s);
     //Reading mouse click
     for( ; ; ){
     //Updating mouse motions
     regs.x.ax=3;int86(0x33,®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("                         ");
     //Printing mouse coordinates
     gotoxy(1,1);textcolor(11);textbackground(6);
     cprintf(" Mouse Position:(%3d,%3d)",regs.x.cx,regs.x.dx);
     while(kbhit()){exit(0);}
    }
}
حامد شیرزاد بازدید : 2669 شنبه 28 آبان 1390 نظرات (0)
Binary Search Tree
 
#include<iostream.h>
#include<conio.h>
#include<alloc.h>
 
struct tree
 {
  int data;
  tree *left;
  tree *right;
 }*sptr,*q;
  void rightcheck();
  void leftcheck();
  void search();
 
  int insdata;
  tree *node;
  void main()
   {
    clrscr();
    node=new tree;
    cout<<"   PLEASE  PUT  THE root->>";
    cin>>node->data;
    sptr=node;
    q=sptr;
    node->left=NULL;
    node->right=NULL;
    cout<<"   GIVE THE child->>";
    cin>>insdata;
    search();
    while(insdata!=0)
    {
     if(insdata>sptr->data)
        rightcheck();
     else
        leftcheck();
        cout<<"   GIVE  THE  child->>";
        cin>>insdata;
        search();
        sptr=node;
       }
      getch();
      }
     void rightcheck()
       {
     if(sptr->right==NULL)
       {
        cout<<"    "<<insdata<<" IS THE  RIGHT  child of "<<q->data<<endl;
        sptr->right=new tree;
        sptr=sptr->right;
        sptr->data=insdata;
        sptr->left=NULL;
        sptr->right=NULL;
        q=node;
       }
     else
        {
         if(insdata>sptr->data)
          {
           sptr=sptr->right;
           q=sptr;
           if(insdata>sptr->data)
        rightcheck();
        else
        leftcheck();
         }
         else
          {
        sptr=sptr->left;
        q=sptr;
        leftcheck();
          }
         }
    }
         void leftcheck()
    {
         if(sptr->left==NULL)
          {
           cout<<"   "<<insdata<<" IS THE LEFT child of "<<q->data<<endl;
           sptr->left=new tree;
           sptr=sptr->left;
           sptr->data=insdata;
           sptr->right=NULL;
           sptr->left=NULL;
           q=node;
          }
     else{
         if(insdata<sptr->data)
          {
        sptr=sptr->left;
        q=sptr;
        if(insdata>sptr->data)
        rightcheck();
        else
        leftcheck();
          }
         else
          {
        sptr=sptr->right;
        q=sptr;
        rightcheck();}
          }
    }
 
       void search()
    {
       sptr=node;
       while(sptr!=NULL)
    {
      if(insdata==sptr->data)
        {
        cout<<"This is not insertable.";
        cout<<"nInsert child ";
        cin>>insdata;
        search();
        break;
        }
      else
      {
        if(insdata>sptr->data)
        sptr=sptr->right;
        else
        sptr=sptr->left;
     }
       }
     sptr=node;
 
       }
حامد شیرزاد بازدید : 587 شنبه 28 آبان 1390 نظرات (0)

 
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
main()
{
clrscr();
float a,b,c,d,l,m,n,k,p,D,q,r,s,x,y,z;
printf("PROGRAM TO SOLVE THREE VARIABLE LINEAR SIMULTANEOUS
EQUATIONS
 
");
printf("The equations are of the
form:
 
ax+by+cz+d=0
lx+my+nz+k=0
px+qy+rz+s=0
 
");
printf("Enter the coefficients in the order a,b,c,d,l,m,n,k,p,q,r,s
");
scanf("%f%f%f%f%f%f%f%f%f%f%f%f",&a,&b,&c,&d,&l,&m,&n,&k,&p,&q,&r,&s);
printf("
The equations you have input are:
 
");
printf("  %.2f*x + %.2f*y + %.2f*z + %.2f = 0
",a,b,c,d);
printf("  %.2f*x + %.2f*y + %.2f*z + %.2f = 0
",l,m,n,k);
printf("  %.2f*x + %.2f*y + %.2f*z + %.2f = 0
 
",p,q,r,s);
 
 D = (a*m*r+b*p*n+c*l*q)-(a*n*q+b*l*r+c*m*p);
 x = ((b*r*k+c*m*s+d*n*q)-(b*n*s+c*q*k+d*m*r))/D;
 y = ((a*n*s+c*p*k+d*l*r)-(a*r*k+c*l*s+d*n*p))/D;
 z = ((a*q*k+b*l*s+d*m*p)-(a*m*s+b*p*k+d*l*q))/D;
 
printf("The solutions to the above three equations are :
 
");
printf("  x = %5.2f
  y = %5.2f
  z = %5.2f
",x,y,z);
getch();
return 0;
}
حامد شیرزاد بازدید : 1463 شنبه 28 آبان 1390 نظرات (0)
Ultimate sol. to world famous game Sudoku
 
/* SU DOKU */
 
#include <iostream.h>
void main()
{
    int k[9][9],K[9][9];
    int i,j,i1,j1,i2,j2;
    int error,temp;
    int count=0;
 
    for(i=0;i<9;i++)
    for(j=0;j<9;j++)
        K[i][j]=0;
 
    for(i=0;i<9;i++)
    for(j=0;j<9;j++)
    {
        cin>>K[i][j];
        k[i][j]=K[i][j];
    }
    cout<<"O.K.? (Enter 0 if OK, 1 to update): ";
    cin>>error;
    if(error==0)
        goto matrixvalidation;
 
matrixupdation:
    while(1)
    {
        cout<<"Enter Row, Col, Revised number:(0 to exit) ";
        cin>>i;
        if(i==0)break;
        cin>>j>>temp;
        if(i>0&&j>0&&temp>=0&&i<10&&j<10&&temp<10)
        {
            K[i-1][j-1]=temp;
            k[i-1][j-1]=temp;
        }
        else
            cout<<"Enter row/column 1 to 9 & number 0 to 9 only.
";
    }
 
matrixvalidation:
    cout<<"
Input matrix:
";
    for(i=0;i<9;i++)
    {
        for(j=0;j<9;j++)
            cout<<k[i][j]<<" ";
        cout<<"
";
    }
 
    for(i=0;i<9;i++)
    for(j=0;j<9;j++)
        if(k[i][j]<0||k[i][j]>9)
        {
            cout<<"
"<<i+1<<" "<<j+1<<" "<<k[i][j];
            cout<<"
Input matrix error.";
            cout<<"
Numbers should be 1 to 9 only.
 
";
            goto matrixupdation;
        }
 
    for(i=0;i<9;i++)
    for(j=0;j<9;j++)
    {
        if(k[i][j]==0)continue;
        error=0;
        for(i1=0;i1<9;i1++)
            if(i!=i1&&k[i][j]==k[i1][j])
            {
                error=1;
                i2=i1;
                j2=j;
            }
        for(j1=0;j1<9;j1++)
            if(j!=j1&&k[i][j]==k[i][j1])
            {
                error=1;
                i2=i;
                j2=j1;
            }
        for(i1=0;i1<9;i1++)
        for(j1=0;j1<9;j1++)
            if((i!=i1||j!=j1)&&i/3==i1/3&&j/3==j1/3&&k[i][j]==k[i1][j1])
            {
                error=1;
                i2=i1;
                j2=j1;
            }
        if(error)
        {
            cout<<"
"<<i+1<<" "<<j+1<<" "<<k[i][j];
            cout<<"
"<<i2+1<<" "<<j2+1<<" "<<k[i2][j2];
            cout<<"
Input matrix error.";
            cout<<"
A number has been repeated in the same row, col or
block.
 
";
            goto matrixupdation;
        }
    }
 
/* Logic starts: */
    for(i=0;i<9;i++)
    for(j=0;j<9;j++)
    {
        if(K[i][j]>0) goto chksol;
        for(k[i][j]++;k[i][j]<=9;k[i][j]++)
        {
            error=0;
            for(i1=0;i1<9;i1++)
                if(i!=i1&&k[i][j]==k[i1][j])error=1;
            for(j1=0;j1<9;j1++)
                if(j!=j1&&k[i][j]==k[i][j1])error=1;
            for(i1=0;i1<9;i1++)
            for(j1=0;j1<9;j1++)
                if((i!=i1||j!=j1)&&i/3==i1/3&&j/3==j1/3&&k[i][j]==k[i1][j1])
                    error=1;
            if(error==0)break;
        }
        if(k[i][j]>9)
        {
            k[i][j]=0;
            do
            {
                if(i==0&&j==0)goto nomoresol;
                if(j>0)j--;else{j=8;i--;}
            }while(K[i][j]>0);
            j--;
        }
chksol:    if(i==8&&j==8)
        {
حامد شیرزاد بازدید : 1048 شنبه 28 آبان 1390 نظرات (0)
عزیزانی که درس محاسبات عددی روگذرونده باشند با این روش ها آشنایی دارند. در اینجا کد پیاده سازی این الگوریتم ها رو برای مطالعه بیشتر قرار میدم
Jacobi itterative and gauss seidal method to solve roots
 
this is a program from numerical to calculate the root of
the given system ,it will check its conditions and then perform the
operation on that system,esle it will tell u that system is not diagonally dominent 
,,,,in this program the functions used can be used in other program ,,
 
 
#include<iostream.h>
#include<conio.h>
#include<math.h>
#include<iomanip.h>
 
float a1[4],a2[4],a3[4];                       /* Array declaration */
void show();                                   /* function declaration 
*/
void getdata(float [],float [],float []);      /*    //   //    //    
*/
void display(float [],float [],float []);      /*    //   //    //    
*/
int diagonally();
void swap(float [],float []);                  /*    //   //    //    
*/
void jacobi(float [],float [],float []);       /*    //   //    //    
*/
void gauss(float [],float [],float []);
void answer();
/*^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^*
/
/*....................MAIN FUNCTION OF METHOD............*/
void main()                              /* main function definition   
*/
  {
      int  count=4;                           /* { main function body} 
*/
      clrscr();
 
cout<<"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^"<<endl;
      cout<<"..................THIS IS VALID ONLY FOR JACOBI ITTERATIVE
METHOD............."<<endl;
 
cout<<"___________________________________________________________________
___________"<<endl;
      show();                            /*  function calling  */
      getdata(a1,a2,a3);                 /*  function calling  */
      clrscr();
      cout<<endl<<endl;
      display(a1,a2,a3);                    /*  function calling  */
      count=diagonally();                   /*  function calling  */
      switch (count)
     {
      case 0:
           {
        answer();        /*  function calling */
        break;
           }
      case 2:
           {display(a1,a2,a3);
        answer();       /*  function calling */
        break;
           }
      default:
           {
        cout<<"SORRY;YOUR SYSTEM IS NOT DIAGONALLY DOMINENT";
        break;
           }
     }
 getch();
  }
////////////////////////Function To Check
Diagonality////////////////////////
int diagonally()
  {
     int f=4,g=4 ,h=4;
     int count=0;
     float temp[4];
     if(fabs(a1[0])<(fabs(a1[1])+fabs(a1[2])))
    {count++;  f=1;}
     if(fabs(a2[1])<(fabs(a2[0])+fabs(a2[2])))
    {count++;  g=2;}
     if(fabs(a3[2])<(fabs(a3[0])+fabs(a3[1])))
    {count++;  h=3;}
     if(f==1&&g==2&&h==4)
    swap(a1,a2);                           /*  function calling  */
     if(f==1&&h==3&&g==4)
    swap(a1,a3);                           /*  function calling  */
     if(g==2&&h==3&&f==4)
    swap(a2,a3);                           /*  function calling  */
 
   return(count);
  }
////////////////////////////Function for jacobi itterative
method/////////////////////////
void jacobi(float a[],float b[],float c[]) /*function definition */
  {
     float temp[3];
     long float j1,j2,j3;
     cout<<endl<<"please enter the initial guess:"<<endl;
     cout<<endl<<"X(1) =";
     cin>>j1;
     cout<<endl<<"X(2) =";
     cin>>j2;
     cout<<endl<<"X(3) =";
     cin>>j3;
 
cout<<"-------------------------------------------------------------------
----";
 
cout<<":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::::";
 
cout<<"___________________________________________________________________
____";
     cout<<endl<<endl<<"iterrations #"<<"  "<<"  X(1)"<<"
X(2)"<<"           X(3)";
     cout<<endl<<"   0"<<setw(17)<<j1<<setw(15)<<j2<<setw(14)<<j3;
     cout<<endl;
 
     for(int s=1;s<=20;s++)
     {
      temp[0]=j1;temp[1]=j2;temp[2]=j3;
      j1=(a[3]-a[1]*temp[1]-a[2]*temp[2])/a[0];
      j2=(b[3]-b[0]*temp[0]-b[2]*temp[2])/b[1];
      j3=(c[3]-c[0]*temp[0]-c[1]*temp[1])/c[2];
      cout<<"   "<<s<<setw(17)<<j1<<setw(15)<<j2<<setw(14)<<j3<<endl;
      if(j1==temp[0]&&j2==temp[1]&&j3==temp[2])
         break;
     }
  }
//////////////////////////Function Of
Swaping////////////////////////////////////
void swap(float a[],float b[])          /*  function definition   */
  {
   float temp[4];
 
cout<<"-------------------------------------------------------------------
-------------"<<endl;

تعداد صفحات : 6

درباره ما
به نام آنکه جان را فکرت آموخت در این وبلاگ سعی می شود به صورت تخصصی به مباحث مربوط به مهندسی نرم افزار به خصوص برنامه نویسی کامپیوتری پرداخته شود. مدیر وبلاگ : حامد شیرزاد
اطلاعات کاربری
  • فراموشی رمز عبور؟
  • آمار سایت
  • کل مطالب : 431
  • کل نظرات : 9
  • افراد آنلاین : 3
  • تعداد اعضا : 109
  • آی پی امروز : 8
  • آی پی دیروز : 43
  • بازدید امروز : 10
  • باردید دیروز : 135
  • گوگل امروز : 0
  • گوگل دیروز : 2
  • بازدید هفته : 216
  • بازدید ماه : 145
  • بازدید سال : 28,165
  • بازدید کلی : 693,340
  • کدهای اختصاصی

    قالب وبلاگ