শনিবার, ৬ ফেব্রুয়ারি, ২০১৬

reverse string by c++

#include<iostream>
using namespace std;

int main()
{
    char ch[10][100];
    int i, n;
    cout << "Enter number how many  string you revers: ";
    cin >> n;
    for(i = 0; i < n; i++)
    {
        cin >> ch[i];
    }
     for(i = n- 1; i >= 0; i--)
            cout << ch[i] << endl;

    return 0;
}


ahmed shuvo969

check a string weather is palindrome or not by c++

#include<iostream>
using namespace std;

int main( )
{
    char str[80];
    cout<<"Enter string: ";
    cin.getline(str, 80);

    int l;
    for(l = 0; str[l] != '\0'; l++);
    int i;
    for(i = 0; (i < l/2) && (str[i] == str[l - i - 1]); i++);

    if(i == l/2)
        cout << "Palindrome";
    else
        cout << "Not a palindrome";

    return 0;
}

/// ahmed shuvo969

lightOj 1136 - Division by 3 solve by c++

#include<iostream>
using namespace std;
typedef unsigned int ll;
ll calc(ll k)
{
return (k / 3) * 2 + (k % 3 == 2 ? 1 : 0);
}
int main()
{
int t, cas = 0;
ll a, b;
cin >> t;
while (t--)
{
cin >> a >> b;
cout << "Case " << ++cas << ": "  << (calc(b) - calc(a - 1)) << endl;
}
return 0;
}


ahmed shuvo969

শুক্রবার, ৫ ফেব্রুয়ারি, ২০১৬

lightOj 1107 - How Cow solve by c++

#include <iostream>
using namespace std;

int main()
{
   int T,t,m,x,y,x1,x2,y1,y2,i;
    cin>>T;
    t=1;
    while(t <= T) {
        cout << "Case " << t << ":" <<endl;
        cin >> x1 >> y1 >> x2 >> y2;
        cin >> m;
        for(i = 0; i < m; i++) {
            cin >> x >> y;
            if(x > x1 && x < x2 && y > y1 && y < y2)
                cout << "Yes" << endl;
            else
                cout << "No" << endl;
       }
       t++;
   }
   return 0;
}

ahmed shuvo969

lightOj 1072 - Calm Down solve by c++

#include<iostream>
#include<iomanip>
#include<math.h>
#define pi 2.0*acos(0.0)


 using namespace std ;
 int main ()
 {
     int t , i  ;
     cin>>t ;
     for (i=1 ; i<=t ; i++)
     {
         double x , n , R ,r ;
         cin >> R >> n;
         x=sin(pi / n);
         r=(x * R) / (1 + x) ;
         cout << setprecision(10) << "Case " << i << ": " << r <<endl ;
     }
     return 0 ;
 }


///ahmed shuvo969

Print closer integer of a double solve by c++

#include<iostream>
#include<math.h>
using namespace std;

int main()
{
    double n;
    cout << "Enter the number : " ;
    cin >> n;
    double t = n - (int)n;
    if(t >= .5)
        cout << ceil(n) << endl;
    else
        cout << floor(n) << endl;

    return 0;
}


///ahmed shuvo969

URI - 1005 solve by c++

#include<iostream>
#include<iomanip>
using namespace std;

int main()
{
   float A, B, MEDIA;
    cin >> A >> B;
     MEDIA =((A*3.5)+(B*7.5))/(3.5+7.5);

    cout << fixed << setprecision(5) <<  "MEDIA = " <<  MEDIA << endl;

    return 0;
}

///ahmed shuvo969