نحوه درخواست برای نوشتن کد

با عرض سلام و خسته نباشید به دوستان دانشجو .

این وبلاگ برای راحتی شما دوستان ایجاد شده تا بتوانید کد های مورد نیاز خود را از آن بردارید .

یک سری از کد ها بصورت طبقه بندی شده موجود است .

برای نوشتن کدهای جدید میتونید با شماره 4442-480-0938 تماس بگیرید .

هزینه نوشتن کدهای جدید به صورت توافقی می باشد .

مثلا نوشتن کدی مثل نمونه کدهای سی و سی پلاس پلاس که موجود است بین 15 تا 20 هزار تومان است .

البته این قیمتها مربوط به سال 1392 می باشد .

نحوه واریز مبلغ به حساب برنامه نویس بصورت تلفنی گفته خواهد شد .

برای ارسال ایمیل به برنامه نویس آدرس زیر موجود است .

Majid_Ahadi@hotmail.com

در صورتی که هرگونه سوالی داشتید با شماره موبایل ذکر شده در قسمت بالا تماس بگیرید .

در صورتی که کد هارو کپی کردید و دیدید کار نمیکنه احتمالا به خاطر سیستم بلاگفاست که نمیشه کد رو کپی کرد و کد رو به عنوان تگ های اچ تی ام ال میبینه ، ایمیل بزنید اصل فایل رو بفرستم .

با تشکر .

1392/6/10


برنامه تمام سرتها

#include iostream.h>
#include stdio.h>
#include conio.h>
void print(int x[], int first)
 {
            for(int k=0;k < first;k++)
                 printf("%d   ,",x[k]);
                cout << endl << endl;
 }
int getarray(int x[],int first)
  {
    int i;
    for(i=0;i    {
        printf("Enter element  %d : ",i+1);
        scanf("%d",&x[i]);
    }
    return (x[first]);
  }
/////////////Shell sort//////////////////////////////////////
void shell_sort (int *a, int n) {
    int h, i, j, k;
    for (h = n; h /= 2;) {
        for (i = h; i < n; i++) {
            k = a[i];
            for (j = i; j >= h && k < a[j - h]; j -= h) {
                a[j] = a[j - h];
            }
            a[j] = k;
        }
    }
}
/////////////Shell sort//////////////////////////////////////
/////////////Merge sort//////////////////////////////////////
void merge(int,int,int,int x[]);
void merge_sort(int low,int high,int x[])
{
 int mid;
 if(low {
  mid=(low+high)/2;
  merge_sort(low,mid,x);
  merge_sort(mid+1,high,x);
  merge(low,mid,high,x);
 }
}
void merge(int low,int mid,int high,int x[])
{
 int h,i,j,b[50],k;
 h=low;
 i=low;
 j=mid+1;

 while((h<=mid)&&(j<=high))
 {
  if(x[h]<=x[j])
  {
    b[i]=x[h];
   h++;
  }
  else
  {
    b[i]=x[j];
   j++;
  }
  i++;
 }
 if(h>mid)
 {
  for(k=j;k<=high;k++)
  {
    b[i]=x[k];
    i++;
  }
 }
 else
 {
  for(k=h;k<=mid;k++)
  {
    b[i]=x[k];
   i++;
  }
 }
 for(k=low;k<=high;k++) x[k]=b[k];
}
/////////////Merge sort//////////////////////////////////////
/////////////Radix sort//////////////////////////////////////
void radixsort(int a[],int n)
{
        int i,b[8],m=0,exp=1;
        for(i=0;i        {
            if(a[i]>m)
                m=a[i];
        }

        while(m/exp>0)
        {
            int bucket[10]={0};
            for(i=0;i                bucket[a[i]/exp%10]++;
            for(i=1;i<10;i++)
                bucket[i]+=bucket[i-1];
            for(i=n-1;i>=0;i--)
                b[--bucket[a[i]/exp%10]]=a[i];
            for(i=0;i                a[i]=b[i];
            exp*=10;

          }
    }
/////////////Radix sort//////////////////////////////////////
/////////////Heap sort//////////////////////////////////////
void siftDown(int numbers[], int root, int bottom) {
  int maxChild = root * 2 + 1;

  // Find the biggest child
  if(maxChild < bottom) {
     int otherChild = maxChild + 1;
     // Reversed for stability
     maxChild = (numbers[otherChild] > numbers[maxChild])?otherChild:maxChild;
  } else {
     // Don't overflow
     if(maxChild > bottom) return;
  }

  // If we have the correct ordering, we are done.
  if(numbers[root] >= numbers[maxChild]) return;

  // Swap
  int temp = numbers[root];
  numbers[root] = numbers[maxChild];
  numbers[maxChild] = temp;

  // Tail queue recursion. Will be compiled as a loop with correct compiler switches.
  siftDown(numbers, maxChild, bottom);
}
void heapSort(int numbers[], int array_size) {
  int i, temp;

  for (i = (array_size / 2); i >= 0; i--) {
     siftDown(numbers, i, array_size - 1);
  }

  for (i = array_size-1; i >= 1; i--) {
     // Swap
     temp = numbers[0];
     numbers[0] = numbers[i];
     numbers[i] = temp;

     siftDown(numbers, 0, i-1);
  }
}
/////////////Heap sort//////////////////////////////////////
/////////////Quick sort//////////////////////////////////////
  void quickSort(int arr[], int left, int right)
  {

        int i = left, j = right;

        int tmp;

        int pivot = arr[(left + right) / 2];



        /* partition */

        while (i <= j) {

                while (arr[i] < pivot)

                        i++;

                while (arr[j] > pivot)

                        j--;

                if (i <= j) {

                        tmp = arr[i];

                        arr[i] = arr[j];

                        arr[j] = tmp;

                        i++;

                        j--;

                }

        };

        /* recursion */

        if (left < j)

                quickSort(arr, left, j);

        if (i < right)

                quickSort(arr, i, right);

}
/////////////Quick sort//////////////////////////////////////
/////////////tree sort//////////////////////////////////////
struct tree{

     int info;

     tree *Left, *Right;

};

tree *root;

class TreeSort{

     public:

          int no_of_elements;

          int elements[10];

     public:

          void getarray();

          void sortit();

          void insert1(int);

          tree *insert2(tree *, tree *);

          void display(tree *);

};

void TreeSort::getarray(){

     cout<<"How many elements? ";

     cin>>no_of_elements;

     cout<<"Insert array of element to sort: ";

     for(int i=0;i
          cin>>elements[i];

     }

}

void TreeSort::sortit(){

     for(int i = 0; i  < no_of_elements; i++){

          insert1(elements[i]);

     }

}

tree* TreeSort::insert2(tree *temp,tree *newnode){

     if(temp==NULL){

          temp=newnode;

     }

     else if(temp->info < newnode->info){

          insert2(temp->Right,newnode);

          if(temp->Right==NULL)

                temp->Right=newnode;

     }

     else{

          insert2(temp->Left,newnode);

          if(temp->Left==NULL)

                temp->Left=newnode;

     }

     return temp;

}

void TreeSort::insert1(int n){

     tree *temp=root,*newnode;

     newnode=new tree;

     newnode->Left=NULL;

     newnode->Right=NULL;

     newnode->info=n;

     root=insert2(temp,newnode);

}

/* Inorder traversal */

void TreeSort::display(tree *t = root){

     if(root==NULL){

          cout<<"Nothing to display";

     }else

     if(t!=NULL){

          display(t->Left);

          cout<info<<" ";

          display(t->Right);

     }

}
/////////////tree sort//////////////////////////////////////

int main(){
int a=1;
while(a>=1){
  cout<<"What kind Of sort You Want :"<     <<"1-  Selection Sort "<     <<"2-  Bubble Sort "<     <<"3-  Insertion Sort "<     <<"4-  Exchange Sort "<     <<"5-  Quick Sort "<     <<"6-  Heap Sort "<     <<"7-  Merge Sort "<     <<"8-  Tree Sort "<     <<"9-  Radix Sort "<     <<"10- Shell Sort "<     <<"0-  Exit"<cin>>a;
    switch (a)
    {
        case 1:
                 {
                         int* x;
                         int first,i,j,max,index;
                         printf("Enter Size of aray : ");
                         scanf("%d",&first);
                         x=new int[first];
                         getarray(x,first);
                             for(i=first-1;i>=0;i--)
                                    {
                                        max=x[0];
                                        index=0;
                                        for(j=0;j<=i;j++)
                                             if(x[j]>max)
                                                  {
                                                     max=x[j];
                                                     index=j;
                                                  }
                                        x[index]=x[i];
                                        x[i]=max;
                                    }
                        print(x,first);
                 }
        break;
        case 2:
                 {
                         int* x;
                         int first,i,temp;
                         printf("Enter Size of aray : ");
                         scanf("%d",&first);
                         x=new int[first];
                         getarray(x,first);
                         int flag = 0;
                         int pass=1;
                         while(pass<=first&&flag==0)
                             {
                                 flag=1;
                                 for(i=0;i<=first-pass-1;i++)
                                     if(x[i]>x[i+1])
                                            {
                                              flag=0;
                                              temp=x[i];
                                              x[i]=x[i+1];
                                              x[i+1]=temp;
                                            }
                              pass=pass+1;
                             }
                         print(x,first);
                 }
        break;
        case 3:
                 {
                         int* x;
                         int first,i,j,y;
                         printf("Enter Size of aray : ");
                         scanf("%d",&first);
                         x=new int[first];
                         getarray(x,first);
                     for(i=1;i<=first-1;i++)
                            {
                              y=x[i];
                              j=i-1;
                              while(j>=0&&y                                     {
                                         x[j+1]=x[j];
                                         j=j-1;
                                     }
                              x[j+1]=y;
                            }
                        print(x,first);
                 }
        break;
        case 4:
                 {
                         int* x;
                         int first,i,j,temp;
                         printf("Enter Size of aray : ");
                         scanf("%d",&first);
                         x=new int[first];
                         getarray(x,first);
                     for(i=0;i<=first-1;i++)
                            for(j=i+1;j                                if(x[i]>x[j])
                                        {
                                            temp=x[i];
                                            x[i]=x[j];
                                            x[j]=temp;
                                        }
                        print(x,first);
                 }
        break;
        case 5:
                 {
                         int* x;
                         int first,left=0;
                         printf("Enter Size of aray : ");
                         scanf("%d",&first);
                         x=new int[first];
                         getarray(x,first);
                        quickSort(x,left,first);
                        print(x,first);
                 }
        break;
        case 6:
                 {
                         int* x;
                         int first;
                         printf("Enter Size of aray : ");
                         scanf("%d",&first);
                         x=new int[first];
                         getarray(x,first);
                    heapSort(x,first);
                    print(x,first);
                 }
        break;
        case 7:
                 {
                         int* x;
                         int first;
                         printf("Enter Size of aray : ");
                         scanf("%d",&first);
                         x=new int[first];
                         getarray(x,first);
                    merge_sort(0,first,x);
                    print(x,first);
                 }
        break;
        case 8:
                 {
                    TreeSort TS;
                    TS.getarray();
                    TS.sortit();
               cout<                    TS.display();
               cout<                 }
        break;
        case 9:
                 {
                         int* x;
                         int first;
                         printf("Enter Size of aray : ");
                         scanf("%d",&first);
                         x=new int[first];
                         getarray(x,first);
                         radixsort(x,first);
                         print(x,first);
                 }
        break;
        case 10:
                 {
                         int* x;
                         int first;
                         printf("Enter Size of aray : ");
                         scanf("%d",&first);
                         x=new int[first];
                         getarray(x,first);
                         shell_sort(x,first);
                         print(x,first);
                 }
        break;
        default: break;
     
     }
}
    getch();
     return 0;

}

سرت درختی Tree Sort

#include iostream.h>
#include stdio.h>
#include conio.h>
/////////////tree sort//////////////////////////////////////
struct tree{

     int info;

     tree *Left, *Right;

};

tree *root;

class TreeSort{

     public:

          int no_of_elements;

          int elements[10];

     public:

          void getarray();

          void sortit();

          void insert1(int);

          tree *insert2(tree *, tree *);

          void display(tree *);

};

void TreeSort::getarray(){

     cout<<"How many elements? ";

     cin>>no_of_elements;

     cout<<"Insert array of element to sort: ";

     for(int i=0;i
          cin>>elements[i];

     }

}

void TreeSort::sortit(){

     for(int i = 0; i  <  no_of_elements; i++){

          insert1(elements[i]);

     }

}

tree* TreeSort::insert2(tree *temp,tree *newnode){

     if(temp==NULL){

          temp=newnode;

     }

     else if(temp->info < newnode->info){

          insert2(temp->Right,newnode);

          if(temp->Right==NULL)

                temp->Right=newnode;

     }

     else{

          insert2(temp->Left,newnode);

          if(temp->Left==NULL)

                temp->Left=newnode;

     }

     return temp;

}

void TreeSort::insert1(int n){

     tree *temp=root,*newnode;

     newnode=new tree;

     newnode->Left=NULL;

     newnode->Right=NULL;

     newnode->info=n;

     root=insert2(temp,newnode);

}

/* Inorder traversal */

void TreeSort::display(tree *t = root){

     if(root==NULL){

          cout<<"Nothing to display";

     }else

     if(t!=NULL){

          display(t->Left);

          cout<info<<" ";

          display(t->Right);

     }

}
/////////////tree sort//////////////////////////////////////

int main()
 {
     
           TreeSort TS;
           TS.getarray();
           TS.sortit();
               cout < < endl;
           TS.display();
               cout < < endl < < endl;
                 
               getch();
           return 0;
 }

سرت صدفی Shell Sort

#include iostream.h>
#include stdio.h>
#include conio.h>
int getarray(int x[],int first)
  {
    int i;
    for(i=0;i    {
        printf("Enter element  %d : ",i+1);
        scanf("%d",&x[i]);
    }
    return (x[first]);
  }
/////////////Shell sort//////////////////////////////////////
void shell_sort (int *a, int n) {
    int h, i, j, k;
    for (h = n; h /= 2;) {
        for (i = h; i < n; i++) {
            k = a[i];
            for (j = i; j >= h && k < a[j - h]; j -= h) {
                a[j] = a[j - h];
            }
            a[j] = k;
        }
    }
}
/////////////Shell sort//////////////////////////////////////
int main()
 {
     
        int* x;
            int first;
        printf("Enter Size of aray : ");
        scanf("%d",&first);
        x=new int[first];
        getarray(x,first);
        shell_sort(x,first);
        for(int k=0;k <=first;k++)
             printf("%d   ,",x[k]);
       cout< < endl < < endl;
        getch();
        return 0;
 }

سرت انتخابی Selection Sort

#include iostream.h>
#include stdio.h>
#include conio.h>
int getarray(int x[],int first)
  {
    int i;
    for(i=0;i    {
        printf("Enter element  %d : ",i+1);
        scanf("%d",&x[i]);
    }
    return (x[first]);
  }
int main()
 {
     
        int* x;
            int first,left=0,i,j,max,index;
        printf("Enter Size of aray : ");
        scanf("%d",&first);
        x=new int[first];
        getarray(x,first);
                for(i=first-1;i>=0;i--)
           {
            max=x[0];
            index=0;
            for(j=0;j<=i;j++)
                   if(x[j]>max)
                 {
                 max=x[j];
                 index=j;
                 }
            x[index]=x[i];
            x[i]=max;
           }
for(int k=0;k <=first;k++)

     printf("%d   ,",x[k]);
       cout< < endl < < endl;
       
getch();
            return 0;
 }

سرت رادیویی Radios Sort

#include iostream.h>
#include stdio.h>
#include conio.h>
int getarray(int x[],int first)
  {
    int i;
    for(i=0;i    {
        printf("Enter element  %d : ",i+1);
        scanf("%d",&x[i]);
    }
    return (x[first]);
  }
/////////////Radix sort//////////////////////////////////////
void radixsort(int a[],int n)
{
        int i,b[8],m=0,exp=1;
        for(i=0;i        {
            if(a[i]>m)
                m=a[i];
        }

        while(m/exp>0)
        {
            int bucket[10]={0};
            for(i=0;i                bucket[a[i]/exp%10]++;
            for(i=1;i<10;i++)
                bucket[i]+=bucket[i-1];
            for(i=n-1;i>=0;i--)
                b[--bucket[a[i]/exp%10]]=a[i];
            for(i=0;i                a[i]=b[i];
            exp*=10;

          }
    }
/////////////Radix sort//////////////////////////////////////

int main()
 {
     
        int* x;
            int first;
        printf("Enter Size of aray : ");
        scanf("%d",&first);
        x=new int[first];
        getarray(x,first);
        radixsort(x,first);
for(int k=0;k <=first;k++)

     printf("%d   ,",x[k]);
       cout< < endl < < endl;
       
getch();
            return 0;
 }

سرت سریع  Quick Sort

#include iostream.h>
#include stdio.h>
#include conio.h>
int getarray(int x[],int first)
  {
    int i;
    for(i=0;i    {
        printf("Enter element  %d : ",i+1);
        scanf("%d",&x[i]);
    }
    return (x[first]);
  }

/////////////Quick sort//////////////////////////////////////
  void quickSort(int arr[], int left, int right)
  {

        int i = left, j = right;

        int tmp;

        int pivot = arr[(left + right) / 2];



        /* partition */

        while (i <= j) {

                while (arr[i] < pivot)

                        i++;

                while (arr[j] > pivot)

                        j--;

                if (i <= j) {

                        tmp = arr[i];

                        arr[i] = arr[j];

                        arr[j] = tmp;

                        i++;

                        j--;

                }

        };

        /* recursion */

        if (left < j)

                quickSort(arr, left, j);

        if (i < right)

                quickSort(arr, i, right);

}
/////////////Quick sort//////////////////////////////////////
int main()
 {
     
        int* x;
            int first,left=0;
        printf("Enter Size of aray : ");
        scanf("%d",&first);
        x=new int[first];
        getarray(x,first);
        quickSort(x,left,first);
        for(int k=0;k < first; k++)
             printf("%d   ,",x[k]);
        cout< < endl < < endl;
                getch();

            return 0;
 }

سرت ادغامی Merge Sort

#include iostream.h>
#include stdio.h>
#include conio.h>
int getarray(int x[],int first)
  {
    int i;
    for(i=0;i    {
        printf("Enter element  %d : ",i+1);
        scanf("%d",&x[i]);
    }
    return (x[first]);
  }
/////////////Merge sort//////////////////////////////////////
void merge(int,int,int,int x[]);
void merge_sort(int low,int high,int x[])
{
 int mid;
 if(low {
  mid=(low+high)/2;
  merge_sort(low,mid,x);
  merge_sort(mid+1,high,x);
  merge(low,mid,high,x);
 }
}
void merge(int low,int mid,int high,int x[])
{
 int h,i,j,b[50],k;
 h=low;
 i=low;
 j=mid+1;

 while((h<=mid)&&(j<=high))
 {
  if(x[h]<=x[j])
  {
    b[i]=x[h];
   h++;
  }
  else
  {
    b[i]=x[j];
   j++;
  }
  i++;
 }
 if(h>mid)
 {
  for(k=j;k<=high;k++)
  {
    b[i]=x[k];
    i++;
  }
 }
 else
 {
  for(k=h;k<=mid;k++)
  {
    b[i]=x[k];
   i++;
  }
 }
 for(k=low;k<=high;k++) x[k]=b[k];
}
/////////////Merge sort//////////////////////////////////////


int main()
 {
     
        int* x;
            int first;
        printf("Enter Size of aray : ");
        scanf("%d",&first);
        x=new int[first];
        getarray(x,first);
        merge_sort(0,first,x);
        for(int k=0;k < first ;k++)
             printf("%d   ,",x[k]);
        cout < < endl < < endl;
                getch();
            return 0;
 }

سرت درجی  Insertion Sort

#include iostream.h>
#include stdio.h>
#include conio.h>
int getarray(int x[],int first)
  {
    int i;
    for(i=0;i    {
        printf("Enter element  %d : ",i+1);
        scanf("%d",&x[i]);
    }
    return (x[first]);
  }
int main()
 {
     
        int* x;
            int first,left=0,i,j,y;
        printf("Enter Size of aray : ");
        scanf("%d",&first);
        x=new int[first];
        getarray(x,first);
        for(i=1;i<=first-1;i++)
           {
             y=x[i];
             j=i-1;
             while(j>=0&&y             {
                      x[j+1]=x[j];
                 j=j-1;
             }
            x[j+1]=y;
           }
        for(int k=0;k < first ;k++)
             printf("%d   ,",x[k]);
        cout < < endl < < endl;
                getch();
            return 0;
 }

هیپ سرت Heap Sort

#include iostream.h>
#include stdio.h>
#include conio.h>
int getarray(int x[],int first)
  {
    int i;
    for(i=0;i    {
        printf("Enter element  %d : ",i+1);
        scanf("%d",&x[i]);
    }
    return (x[first]);
  }
/////////////Heap sort//////////////////////////////////////
void siftDown(int numbers[], int root, int bottom) {
  int maxChild = root * 2 + 1;

  // Find the biggest child
  if(maxChild < bottom) {
     int otherChild = maxChild + 1;
     // Reversed for stability
     maxChild = (numbers[otherChild] > numbers[maxChild])?otherChild:maxChild;
  } else {
     // Don't overflow
     if(maxChild > bottom) return;
  }

  // If we have the correct ordering, we are done.
  if(numbers[root] >= numbers[maxChild]) return;

  // Swap
  int temp = numbers[root];
  numbers[root] = numbers[maxChild];
  numbers[maxChild] = temp;

  // Tail queue recursion. Will be compiled as a loop with correct compiler switches.
  siftDown(numbers, maxChild, bottom);
}
void heapSort(int numbers[], int array_size) {
  int i, temp;

  for (i = (array_size / 2); i >= 0; i--) {
     siftDown(numbers, i, array_size - 1);
  }

  for (i = array_size-1; i >= 1; i--) {
     // Swap
     temp = numbers[0];
     numbers[0] = numbers[i];
     numbers[i] = temp;

     siftDown(numbers, 0, i-1);
  }
}
/////////////Heap sort//////////////////////////////////////
int main()
 {
    
        int* x;
            int first;
        printf("Enter Size of aray : ");
        scanf("%d",&first);
        x=new int[first];
        getarray(x,first);
        heapSort(x,first);
        for(int k=0;k < first ;k++)
             printf("%d   ,",x[k]);
        cout < < endl < < endl;
                getch();
            return 0;
 }

سرت تعویضی Exchange Sort

#include iostream.h>
#include stdio.h>
#include conio.h>
int getarray(int x[],int first)
  {
    int i;
    for(i=0;i    {
        printf("Enter element  %d : ",i+1);
        scanf("%d",&x[i]);
    }
    return (x[first]);
  }
int main()
 {
     
        int* x;
            int first,left=0,i,j,temp;
        printf("Enter Size of aray : ");
        scanf("%d",&first);
        x=new int[first];
        getarray(x,first);
        for(i=0;i<=first-1;i++)
            for(j=i+1;j            if(x[i]>x[j])
              {
                temp=x[i];
                x[i]=x[j];
                x[j]=temp;
                  }
        for(int k=0;k < first;k++)
             printf("%d   ,",x[k]);
        cout< < endl < < endl;
                getch();

            return 0;
 }

سرت حبابی Bubble sort

#include iostream.h>
#include stdio.h>
#include conio.h>
int getarray(int x[],int first)
  {
    int i;
    for(i=0;i    {
        printf("Enter element  %d : ",i+1);
        scanf("%d",&x[i]);
    }
    return (x[first]);
  }
int main()
 {
     
        int* x;
            int first,left=0,temp,i;
        printf("Enter Size of aray : ");
        scanf("%d",&first);
        x=new int[first];
        getarray(x,first);
        int flag = 0;
        int pass=1;
        while(pass<=first&&flag==0)
         {
            flag=1;
            for(i=0;i<=first-pass-1;i++)
             if(x[i]>x[i+1])
                    {
                flag=0;
                temp=x[i];
                x[i]=x[i+1];
                x[i+1]=temp;
                }
            pass=pass+1;
         }
        for(int k=0;k < first;k++)
             printf("%d   ,",x[k]);
        cout < < endl < < endl;
                getch();

            return 0;
 }

نوشتن اسمبلی در کامپایلر Borland C++ 4.5

نوشتن اسمبلی در کامپایلر Borland C++ 4.5

#include
#include
#include
int main()
  {
      int n , k , i=0 , l , m;
      scanf("%d",&n);
      int *a = new int [n];
      int index1 , index2 ;
      int bindex1 , bindex2 ;
      int r=1 , bestr=1 ;
      index1 = index2 = 0 ;

      /*  Code C++
      for (int i = 0 ; i < n ; i++ ){
            scanf("%d", &a[i]);
      if(!a[i]) {
          if(r>bestr){
              bindex1 = index1 ;
              bindex2 = index2 - 1;
              bestr = r ;
              }
          r=1  ;
          index1 = index2 = i+1 ;
                    }
      else {
              r *= a[i] ;
              index2 ++ ;
             }
                                                 }
     for(i = bindex1 ; i< bindex2 ; i++ )
          printf( " %d * ", a[i] );
     printf( "  %d = %d ", a[bindex2], bestr );


      */

      __asm {
             MOV AX , r
                 MOV CX , 0
                 L1:
                 MOV CX , i
                 CMP CX , n
                 JAE L2

                }
      scanf("%d",&a[i]);
      k=a[i];
      __asm {

                 CMP k , 0
                 JNE L3
                 MOV BX , bestr
                 CMP BX , r
                 JB L4
                 MOV r , BX
                 MOV BX , bindex1
                 MOV index1 , BX

                 DEC index2
                 MOV BX , index2
                 MOV bindex2 ,BX

                 L4:
                 MOV r , 1
                 MOV index2 , CX
                 INC index2
                 MOV BX , index2
                 MOV index1 , BX
                 L3:
                 CMP k ,0
                 JE L9

                 MUL k

                 INC index2
                 L9:
                 INC i
                 JMP L1
                 L2:
             MOV bestr , AX
                 /*
                 MOV BX , bindex1
                 L5:
                 CMP BX , bindex2
                 JAE L6
              }
      printf("%d * " , a[i]);
      __asm {
                 INC BX
                 JMP L1
                 L6:
              }
      printf("%d = %d",a[bindex2],bestr);*/

             }

     for(i = 0 ; i< n-1 ; i++ )
          printf( " %d * ", a[i] );
     printf( "  %d = %d ", a[n-1], bestr );
        return 0 ;
        getch();
  }

3 آرایه

برنامه ای بنویسید که دو آرایه n عنصری را از ورودی گرفته و پس از مرتب کردن آنها در یک آرایه سوم به صورت مرتب شده ادغام کند . برای دریافت و مرتب سازی و ادغام از 3 تابع مجزا استفاده کنید .

int get(int Aray1[] ,int first , int Aray2[] , int second);
int sort(int Aray1[] ,int first , int Aray2[] , int second);
int combine(int Aray1[] ,int first , int Aray2[] , int second , int Aray3[], int x);
int print(int Aray3[] , int x);
int main()
{
    int x;
// Size Of Arrays
    int* Aray1;
    int* Aray2;
    int* Aray3;
    int first,second;
    printf("Enter Size of First aray : ");
    scanf("%d",&first);
    Aray1=new int[first];

    printf("Enter Size of second aray: ");
    scanf("%d",&second);
    Aray2=new int[second];

    x=first+second;
    Aray3=new int[x];



get(Aray1 ,first , Aray2 , second );
sort(Aray1 ,first , Aray2 , second );
combine (Aray1 ,first , Aray2 , second , Aray3 , x );
print ( Aray3 , x);
getch();
return 0;
}

//#################################

int sort(int Aray1[] ,int first , int Aray2[] , int second)
{
cout<int i , j , t ;
for(i=1;i<=first;i++)
 for(j=0;j<=first-i;j++)
    if (Aray1[j]>Aray1[j+1])
     {
        t = Aray1[j];
        Aray1[j]=Aray1[j+1];
        Aray1[j+1] = t;
     }

for(i=1;i<=second;i++)
 for(j=0;j<=second-i;j++)
    if (Aray2[j]>Aray2[j+1])
     {
        t = Aray2[j];
        Aray2[j]=Aray2[j+1];
        Aray2[j+1] = t;
     }
}


//################################

int print( int Aray3[], int x)
{
cout<int i ;
for(i=0;i     {
        cout<     }


}

//#################################

int combine(int Aray1[] ,int first , int Aray2[] , int second , int Aray3[], int x)
{
cout<int i ;
for(i=0;i     {
        Aray3[i] = Aray1[i];
     }
for(i=0;i     {
        Aray3[i+first] = Aray2[i];
     }

}
//################################

int get(int Aray1[] ,int first , int Aray2[] , int second)
{
    int i ;
    for(i=0;i    {
        printf("Enter element  %d : ",i+1);
        scanf("%d",&Aray1[i]);
    }

    cout<<"enter Second Array Elements "<    for(i=0;i    {
        printf("Enter element  %d : ",i+1);
        scanf("%d",&Aray2[i]);
    }

    printf("The Arrays you have input is:\n");
    for(i=0;i    {
        printf("%d \t",Aray1[i]);
    }
    cout<    for(i=0;i    {
        printf("%d \t",Aray2[i]);
    }

}

عدد رندوم باینری

برنامه ای بنویسید که یک جدول از اعداد باینری در محدوده 1 الی 256 را به نمایش در آورد . برای تبدیل و چاپ عدد دهدهی به باینری از تابع استفاده کنید .


int binary(int n);
int main()
{
int n;
srand(time(0));
n=(rand() % 256 );
if (n==0)
 n++;

printf ("Your Random Decimal number Is ::::::> %d  \n",n);
binary( n );

getch();
return 0;

}

//#################

int binary(int n)
{
int i=15 , k ;

while (n>1)
{
 k=n%2 ;
 gotoxy (i,6);
 printf("%d",k);
 i-=2;
 n=n/2 ;
}

gotoxy (i,6);
printf("%d",n);

printf("\n\n\n*************************************");

}

مقدار e^x

تابعی بنویسید که مقدار e^x را با استفاده از فرمول زیر محاسبه کند

e^x=1+x/1!+x^2/2!+....


float power (float x, float i);
float fact (float i);
int main()
{
 float x , i , j ;
 float w=0 ;
 cout<<"Ta chand jomle mikhahid mohasebe shavad ?? ==> ";
 cin>>i;
 i--;
 cout<<"meghdare X ra vared konid ==> ";
 cin>>x;
 for(j=0;j<=i;j++)
  w+=(power(x,j) / fact(j));

 cout<<"your e^x is : "<
getch();
return 0;
}

//######################

float power (float x , float i)
{
 int j ;
 for(j=0;j<=i;j++)
  x*=x;
 return x;
}

//######################

float fact (float i)
{
int j ;
float k=1;
if(i<=1)
  k=1;
else
 for (j=1;j<=i;j++)
    k=k*j;
return k;
}

ستطیل یک لوزی و یک فلش

برنامه ای بنویسید که بتواند یک مستطیل یک لوزی و یک فلش را همانند الگور زیر با استفاده از کاراکتر * ترسیم کند .

*****            *                          *

*      *         * * *                    *     * 

*      *            *                     *          *

*      *            *                       *     *

******           *                           *

  کد فلش


int main()
{
 int i,j;
 for (i=0;i<5;i+=2)
  {
    if(i==0)
      cout<<"  ";
    if (i==2)
      cout<<" ";
    for(j=0;j<=i;j++)
      {
         cout<<"*";
      }
     cout<  }

 for (i=0;i<6;i++)
  {
     for(j=0;j<1;j++)
      cout<<"  "<<"*";
     cout<  }

 getch();
 return 0;
}


کد مستطیل


int main()
{
 int i,j,k;
 for (i=0;i<9;i++)
  {
     if(i==0||i==8)
      {
         for(j=0;j<10;j++)
          cout<<"*";
      }
     else
        {
          cout<<"*";
          for(k=0;k<8;k++)
            cout<<" ";
        cout<<"*";
        }
     cout<  }
 getch();
 return 0;
}

تکرار عناصر آرایه

برنامه ای بنویسید که یک آرایه n عضوی را از کاربر بگیرد و تعداد دفعات تکرار هر عنصر را در یک ماتریس حداکثر 2*n عنصری ذخیره کند . ماتریس خروجی نباید سطر مشابه داشته باشد . فرض کنیدد صورت ثابت است .

int main()
{
 int c=1,a[5]={4,5,4,4,5},m,i,j;
for(j=0;j<5;j++)
 {
  m=a[j];
  for(i=1;i<5;i++)
    {
     if(a[i]>0)
      {
        if(a[i]==m)
         {
          c++;
          a[j]=0;
          a[i]=0;
         }
      }
    }
  cout<<"Tedad "<  c=1;
 }

getch();
return 0 ;
}

آرایه 20 عضوی

برنامه ای بنویسید که 20 عدد را از کاربر گرفته آن ها در یک آرایه ذخیره کرده ، سپس اعداد زوج را بصورت صعودی از ابتدای آرایه و اعداد فرد را بصورت صعودی از انتهای آرایه مرتب کند .


int main()
{
 int a[20]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20},b[20],i,k,j=0,l=0;
 for(i=0;i<20;i++)
    {
      k=(a[i]%2);
      if(k==0)
      {
         b[l]=a[i];
         l++;
      }
      else
      {
         b[19-j]=a[i];
         j++;
      }
    }
 for(i=0;i<20;i++)
    cout<<"  "<
 getch();
 return 0;
}

کلیه اعداد اول کوچکتر از یک عدد

برنامه ای بنویسید که یک عدد را گرفته و کلیه اعداد اول کوچکتر از آن را چاپ کند . برای پیدا کردن اعداد اول باید از تابع استفاده کنید .

long aval(long n);
int main()
{
 long n ;
 cout<<"please enter number for find aval==>";
 cin>>n;
 cout<  aval(n);
 getch();
 return 0;
}

long aval(long n)
{
 int i , j , c=0;
 for(i=1;i<=n;i++)
 {
  for(j=1;j<=i;j++)
     if(i%j==0)
        c++;
  if(c==2)
    cout<   c=0;
 }
}

عداد تکرارهای یک رقم در یک عدد صحیح

برنامه ای بنویسید که تعداد تکرارهای یک رقم در یک عدد صحیح را با استفاده از تابع پیدا کند


void tekrar(int n);
int main()
{
  int n;
  cout<<"Please Enter number==> ";
  cin>>n;
  tekrar(n);
  getch();
  return 0;
}

void tekrar(int n)
{
 int k,a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0;
  while(n>9)
    {
     k=(n%10);
     
     if(k==1)
        a++;
     if(k==2)
        b++;
     if(k==3)
        c++;
     if(k==4)
        d++;
     if(k==5)
        e++;
     if(k==6)
        f++;
     if(k==7)
        g++;
     if(k==8)
        h++;
     if(k==9)
        i++;
    if(k==0)
        j++;

  n=n/10;
    }

     if(n==1)
        a++;
     if(n==2)
        b++;
     if(n==3)
        c++;
     if(n==4)
        d++;
     if(n==5)
        e++;
     if(n==6)
        f++;
     if(n==7)
        g++;
     if(n==8)
        h++;
     if(n==9)
        i++;
     if(n==0)
        j++;
 if(a>=1)
 cout< if(b>=1)
 cout<<"you entered "< if(c>=1)
 cout<<"you entered "< if(d>=1)
 cout<<"you entered "< if(e>=1)
 cout<<"you entered "< if(f>=1)
 cout<<"you entered "< if(g>=1)
 cout<<"you entered "< if(h>=1)
 cout<<"you entered "< if(i>=1)
 cout<<"you entered "< if(j>=1)
 cout<<"you entered "<}

m بتوان n

تابعی بنویسید که دو عدد m و n را از کاربر گرفته و m را بتوان n برساند

int pow(int m , int n);
int main()
{
 int n=0 , m=0;
 cout<<"please enter m & n for m^n ==>";
 cin>>m>>n ;
 cout< getch();
 return 0;
}
int pow(int m , int n)
{
int i , k=1;
for(i=1;i<=n;i++)
 k*=m;
return k;
}

حاصل عبارت

برنامه بنویسید که حاصل عبارت زیر را محاسبه کند . برای محاسبه فاکتوریل از تابع استفاده کنید .

1 + 1/2! + 1/3!+… + 1/n!



float fact(float n);
int main()
{
 float n ,w=0,i;
 cout<<"You want to determine 1+1/2!+1/3!+...+1/n!"< cout<<"please enter n ==> ";
 cin>>n;
 cout<<"1";
 for(i=0;i {
  cout<<" + ";
  w+=(1/fact(n-i));
 }
 cout<<" = "<<1+w;
 getch();
 return 0;
}
float fact(float n)
{
 float i , k=1;
 for(i=1;i<=n;i++)
  k*=i;
 cout<<(1/k);
 return k;
}

ب م م  - ک م م دو عدد

برنامه ای بنویسید که ب م م و ک م م دوعدد را چاپ کند

int bmm (int n , int m);
int kmm (int n , int m);
int main()
{
 int n=0,m=0,w=0;
 cout<<"please enter n & m ==> ";
 cin>>n>>m;
 w = bmm(n,m);
 if(w>1)
    cout<

عضاء مشترک دو آرایه 10 عنصری

برنامه ای بنویسید که تعداد اعضاء مشترک دو آرایه 10 عنصری را مشخص کرده و آنها را چاپ کند .

int main()
{
 int a1[10]={1,2,3,4,5,6,7,8,9,10},a2[10]={11,12,13,14,15,16,17,18,19,1},i,j,c=0;
 cout<<"your aray is :"< for(i=0;i<10;i++)
 cout<<"  "< cout< for(i=0;i<10;i++)
 cout<<"  "< cout< for(i=0;i<10;i++)
  for(j=0;j<10;j++)
    if(a1[i]==a2[j])
     {
     cout<<"your "<     c++;
     }
 cout< getch();
 return 0;

}

100 جمله اول سری

برنامه ای بنویسید که مجموع 100 جمله اول سری زیر را محاسبه کنید :

1+1/2+1/4+1/8+…



int main()
{
float s=0 , i ,c=0;
cout<<" You want to determine Something Like This   : "<<<"1+1/2+1/4+1/8+1/16+...+1/n" <cout<<" 1 + " ;
i=2 ;
while (c<=99 )
 {
    s+=1/i;
    cout<<1/i<<"+ " ;
    c++;
    i*=2 ;
 }
cout<<" ===== >>>>>"<"<return 0 ;
}

100-110-120

برنامه ای بنویسید که خروجی آن به شکل زیر باشد :

100
110 100
120 110 100
130 120 110 100
140 130 120 110 100
150 140 130 120 110 100
160 150 140 130 120 110 100
170 160 150 140 130 120 110 100
180 170 160 150 140 130 120 110 100
190 180 170 160 150 140 130 120 110 100
200 190 180 170 160 150 140 130 120 110 100



int main()
{
int i ,j ;
for(j=100 ; j<=200 ;j+=10)
 {
    for(i=100 ; i<=j ; i+=10)
     {
        cout<        if(i==j)
         {
            cout<         }
     }
    cout< }
}

معکوس یک عدد

برنامه ای بنویسید که یک عدد را از کاربر گرفته و معکوس آنرا چاپ کند .

int main()
{
int n , k;
cout<<"Please Enter Number ==> ";
cin>>n;
cout<while(n>9)
 {
  k=(n%10);
  cout<  n=n/10;
 }
 cout<}

عدد اول

برنامه ای بنو سید که مشخص کند آیا یک عدد اول است یا خیر .


int main()
{
int n , i ,k ,c=0;
cout<<"Please Enter Number ==> ";
cin>>n;
cout<for( i=1 ; i<=n ; i++ )
 {
  k=(n%i);
  if(k==0)
  c++;
 }
if(c==2)
cout<<"Aval";
else
cout<<"Not Aval";
}

سری فیبوناتچی

برنامه ای بنویسید که یک عدد را بگیرد و مشخص کند جزء سری فیبوناتچی هست یا خیر

int main()
{
int a=1,b=1,n,c=0 ;
cout<<"Please Enter Number ==> ";
cin>>n;
cout<if(n==1)
cout<<"1";
if(n==2)
cout<<"1 , 1";
if(n>2)
 {
  cout<<"1 , 1 ";
  do
  {
    c=a+b ;
    a=b ;
    b=c ;
    if(c>n)
        break ;
    cout<<" , "<
  }while(c<=n);

    cout<
    if(a==n)
      cout<<"Your Number is in Fibunatchi Series";
    else
      cout<<"Your Number is Not in Fibunatchi Series";

    cout<  }

return 0 ;

}