Thursday, March 24, 2016

another

#include<bits/stdc++.h>
using namespace std;

int main()
{
    char get[99],nw[99],l=0;
    gets(get);
    int ln=strlen(get);
    for(int i=0;i<ln;i++)
    {
        for(int j=0;j<ln;j++)
        {
            if(i==j)
                continue;
            else if(get[i]==get[j])
            {
                get[j]=get[j]-33;
            }
        }
    }
    cout<<get<<endl;

    for(int k=0;k<ln;k++)
    {
        if(get[k]>=90&&get[k]<=122)
        {
            nw[l]=get[k];
            l++;
        }
    }
    puts(nw);


    return 0;
}

same practice

#include<bits/stdc++.h>
using namespace std;

int main()
{
    char name[999], namex[999],name2[999];
    int x=50,y=0;
    gets(name);
    //gets(name2);
    int ln=strlen(name);
    //int ln2=strlen(name2);
    for(int i=0; i<ln; i++)
    {
        for(int j=0; j<ln; j++)
        {
            if(i==j)
                continue;
            else if(name[j]==name[i])
                name[j]=name[j]-x;
        }
    }
    for(int i=0; i<ln; i++)
    {
        if(name[i]>=97&&name[i]<=122)
        {
             namex[y]=name[i];
            y++;
        }
    }
    cout<<namex<<endl;

//    / work start for 2nd string
//
//    int a=100,b=0;
//    char name2x[999];
//
//    for(int i=0; i<ln2; i++)
//    {
//        for(int j=0; j<ln2; j++,a++)
//        {
//            if(i==j)
//                continue;
//            else if(name2[j]==name2[i])
//                name2[j]=name2[j]+a;
//        }
//    }
//    for(int i=0; i<ln2; i++)
//    {
//        if(name2[i]>=97&&name2[i]<=122)
//        {
//             name2x[b]=name2[i];
//            b++;
//        }
//    }
//    cout<<name2x<<endl;
//
//    / my desire is namex and name2x
//
//    / work for common character
//    int l=strlen(namex),k=0;
//    int ll=strlen(name2x);
//    char fd[999];
//
//    for(int i=0;i<l;i++)
//    {
//        for(int j=0;j<ll;j++)
//        {
//            if(namex[i]==name2x[j])
//                fd[k]=namex[i];
//                k++;
//        }
//    }
//    cout<<fd<<endl;


    return 0;
}

test 1

#include<bits/stdc++.h>
using namespace std;

int main()
{
    char namex[999],name2x[999],get[999],k=0,l=100,m=0,a[999];
    gets(namex);
    gets(name2x);
    for(int i=0; i<strlen(namex); i++)
    {
        for(int j=0; j<strlen(name2x); j++)
        {
            if(namex[i]==name2x[j])
            {
                get[k]=namex[i];
                k++;
            }
        }
    }

    cout<<get<<endl<<endl;

    ///works for deleting same character
    int x=50,y=0;

    for(int i=0; i<strlen(get); i++)
    {
        for(int j=0; j<strlen(get); j++)
        {
            if(i==j)
                continue;
            else if(get[j]==get[i])
            {
                get[j]=get[j]-x;
                x++;
            }
        }
    }
    for(int i=0; i<strlen(get); i++)
    {
        if(get[i]>=97&&get[i]<=122)
        {
            namex[y]=get[i];
            y++;
        }
    }
    cout<<namex<<endl;



















//    for(int i=0; i<strlen(get); i++)
//    {
//        for(int j=0; j<strlen(get); j++)
//        {
//            if(i==j)
//                continue;
//            if(get[i]==get[j])
//            {
//                get[j]=get[j]+l;
//                l++;
//            }
//        }
//
//    }
//

//    for(int i=0; i<strlen(get); i++)
//    {
//        if(get[i]>=97&&get[i]<=122)
//            a[m]=get[i];
//        m++;
//    }
//    cout<<a<<endl;

    return 0;
}

Wednesday, March 23, 2016

c++ এর জন্য প্রয়োজনীয় টপিক সমূহ

1.Structure
2.Function Overload
3.Kin Cout
4.Templet
5.vector
6.String
7.Stack
8.Queue
9.Priority Queue
10.Etarator
11.Sort
12.Set
13.Map
14.Stringstrim
15.Pair
16.Reverse
17.Next permutation, prib permutation

Wonder of recursive function

রিকার্সিভ ফাংশনরে আগে যদি কোন কাজ থাকে তবে রিকার্সন কাজ করার সাথে সাথে কাজ গুলাও করতে থাকে যদি  না থাকে তবে রিকার্সনের কাজ আগে শেষ করে , তারপর রি কারশন অনুসারে রেজাল্ট দিবে

যেমন

//Bismillah-hir-rah-ma-nir-rahim(in the name of Allah)
//Thinker: Arafat Kamal Tamzid(Sylhet Engineering College)

#include<bits/stdc++.h>
using namespace std;

#define pf printf
#define sc scanf
#define fl float
#define pi acos(-1)


void f(int i, int a)
{
    if(i<=a)
    {

        printf("%d ", i);
        f(i+1, a);
   

    }
}

int main()
{

    int a=5,i=1;
    f(i,a);
    return 0;
}

এর output: 1 2 3 4 5

আর অন্য ভাবে
//Bismillah-hir-rah-ma-nir-rahim(in the name of Allah)
//Thinker: Arafat Kamal Tamzid(Sylhet Engineering College)

#include<bits/stdc++.h>
using namespace std;

#define pf printf
#define sc scanf
#define fl float
#define pi acos(-1)


void f(int i, int a)
{
    if(i<=a)
    {

             f(i+1, a);
  printf("%d ", i);
   

    }
}

int main()
{

    int a=5,i=1;
    f(i,a);
    return 0;
}


এটার আউটপুট হচ্ছে: 5 4 3 2 1

Monday, March 21, 2016

Ready code

//Bismillah-hir-rah-ma-nir-rahim(in the name of Allah)
//Thinker: Arafat Kamal Tamzid(Sylhet Engineering College)

#include<bits/stdc++.h>
using namespace std;

#define pf printf
#define sc scanf
#define db double
#define fl float
#define pi acos(-1)


int main()
{
   
    return 0;
}

efficient code for prime number

#include<bits/stdc++.h>
using namespace std;

bool prime(long long a)
{
    long long b=0,i;
    for(i=2; i*i<=a; i++)
        if(a%i==0)
            return 0;
    return 1;
}


int main()
{
    long long t,m,n;
    cin>>t;
    for(long long i=0; i<t; i++)
    {
        cin>>n>>m;
        for(long long j=n; j<=m; j++)
        {
            if(prime(j)==1&&j!=1)
                cout<<j<<endl;
        }
        cout <<endl;
    }
    return 0;
}

Sunday, March 20, 2016

Short note

delete an element from an array:

for (int i = index; i < /* length */; i++)
        {
            array[index] = array[index+1];
            array[length-1] = 0;
        }


size of an array:

#include<iostream>
using namespace std;
int main()
{
    int a[]={1,2,3,4,5,6};
    int size;
    size=sizeof a/sizeof(int);      //total size of array/size of array data type
    cout<<size;                     
    return 0;
}

another way:

int a[]= {1, 5, 8, 9, 6, 7, 3, 4, 2, 0};
int asize = sizeof(a) / sizeof(a[0]); //size of the array


Wednesday, March 16, 2016

Code for LCD

#include<bits/stdc++.h>
using namespace std;


int main()
{
    int a,b,c;
    cin>>a>>b;
    int e=a, f=b;

    while(b!=0)
    {
        int t=b;
        b=a%b;
        a=t;
    }

    c=(e*f)/a;
    cout<<c<<endl;

    return 0;
}



with function:

//Bismillah-hir-rah-ma-nir-rahim(in the name of Allah)
//Thinker: Arafat Kamal Tamzid(Sylhet Engineering College)

#include<bits/stdc++.h>
using namespace std;

int gcd(int a, int b)
{
    int t,e,f;
    e=a,f=b;
    while(b!=0)
    {
        t=b;
        b=a%b;
        a=t;
    }
    int lcd=(e*f)/a;
    return lcd;
}

int main()
{
    int a,b,c;
    cin>>a>>b;
     c=gcd(a,b);
    cout<<c<<endl;

    return 0;
}


Code for GCD

shortcut for gcd / built in function in c++ for gcd :
int a,b,c;
cin>>a>>b;

c= __gcd(a,b); // here c is the gcd of a,b.



//Bismillah-hir-rah-ma-nir-rahim(in the name of Allah)
//Thinker: Arafat Kamal Tamzid(Sylhet Engineering College)

#include<bits/stdc++.h>
using namespace std;

int gcd(int a, int b)
{
    int t;
    while(b!=0)
    {
        t=b;
        b=a%b;
        a=t;
    }
    return a;
}

int main()
{
    int a,b,c;
    cin>>a>>b;
     c=gcd(a,b);
    cout<<c<<endl;

    return 0;
}



more faster function :

int gcd(int a , int b)
{
   if(b==0) return a;
   a%=b;
   return gcd(b,a);
}

Algoritham for GCD and LCD

gcd(a,b)
while(b!=0)
t=b
b=a%b;
a=t;

return a;

Tuesday, March 15, 2016

নম্বর sort করার code

কোন একটা এলোমেলো array কে সর্ট করার জন্য এটা সবচেয়ে সহজ কোড.


#include<bits/stdc++.h>
using namespace std;

int main()
{
   int a[]={2,3,4,1,8,6,5,7},i;
   sort(a,a+8);
   for(i=0;i<8;i++)
    cout<<a[i]<<endl;

   return 0

}

Speedup Android Studio

Go to Help ->Edit Custom VM Options, and chnge this 4 setting. After that close your Android Studio. This settings are for 8gb of ram pc...