পোস্টগুলি

2D vector

#include<iostream> #include<vector> using namespace std; int fun(vector< vector<int> > vec){     for(int i=0;i<vec.size();i++){         for(int j=0;j<vec[i].size();j++){             cout<<vec[i][j]<<' ';         }cout<<endl;     }     return 0; } int main(){     int row{10},col{10};     vector< vector<int> > vec(row,vector<int>(col,-1));     vec[3][3]=3432;     vec[3].push_back(1212);     vector<int> sub;     sub.push_back(4);     sub.push_back(3);     sub.push_back(2);     vec.push_back(sub);     fun(vec); }

শিরোনামহীন গল্প

  শিরোনামহীন গল্প   শিক্ষক হলেন একজন সম্মানিত এবং শ্রদ্ধেয় ভাজন ব্যাক্তি। কিন্তু কখনো কখনো কারোর কাছে ভয়ের কারন হয়ে দারায়। তেমনি একটা ঘটনা আজ আমি বর্ননা করতে চলেছি। JSC তে ভালো রেজাল্ট নাকরার জন্য স্কুল থেকে আমাকে বিজ্ঞান বিভাগে পড়ার সুযোগ দিতে চাচ্ছিলোনা। পড়ে একজন পারিবারিক শিক্ষক(আমার দূর সম্পর্কের একজন দুলাভাই) এর সুপারিসে সেই সুজগ   পেয়েছিলাম। কিন্তু SSC তে ভালো ফলাফল আনতে পারলাম না। বলতে গেলে কোনোমতে পাস করেছি মাত্র। যা ছিলো যেকোনো কলেজে বিজ্ঞান বিভাগে পড়ার নূন্যতম যগ্যতা থেকেও কম। কিন্তু আমার পরিবার থেকে চাচ্ছিলো আমি যেনো পড়ালিখা চালিয়ে যাই।সায়েন্স না পাইলেও যেনো আর্স কিম্বা কমার্সে হইলেও পড়ালেখা বাদ না দেই। এমন সময় আমি জেদ ধরে বসি সায়েন্স না পাইলে পড়ালিখা ছেড়ে দেবো। শেষ পর্যন্ত ফুপাতো ভাই এর শুপারিসে আমার ইচ্ছাই পুরন করা হইলো, কিন্তু শেষ বারের মতো।আপনাদের নিশ্চয় এতোক্ষনে আমার সম্পর্কে একটা ধারনা হয়েই গেছে।যাইহোক এইবার মূল ঘটনায় আসা যাক। কলেজে এসে ফেল করতে করতে ২য় বর্ষে উঠেগেলাম। ততোটাও খারাপ ছাত্র ছিলাম না, year change পরীক্ষায় কনোমতে পাস করেই ২য় বর্ষে উঠেছিলাম...

Sort Class object

ছবি
 Code: #include<iostream> #include<algorithm> using namespace std; class Candidates{     string name;     int age;     double cgpa; public:     Candidates(){     }     Candidates(string name,int age,double cgpa){         this->name = name;         this->age = age;         this->cgpa = cgpa;     }     void print(){         cout<<"Name : "<<name<<'\t';         cout<<"Age : "<<age<<'\t'<<"CGPA : "<<cgpa<<endl;     }     bool operator<(const Candidates ca)const{         if(cgpa>ca.cgpa){//increasing order CGPA             return true;         }else if(cgpa==ca.cgpa){             if(age<ca.age){//decreasing or...

1022 TDA Rational(Play with oop)

URI 1022 TDA Rational : It is so easy problem. so after see solution try your self. It can be solve various way.But i am use OOP for practicing OOP.And i am use some extra thing. If you solve the problem.But it is not accepted than use uDebug to find out the BUG. Here is the problem  uDebug Link . C++ code:   #include<iostream> #include<math.h> using namespace std; int GCD(int num1,int num2){     if(num1%num2==0){         return num2;     }else{         return GCD(num2,num1%num2);     } } class rational{ private:     int numerator{0};     int denominator{0}; public:     void setData(int numerator,int denominator){         this->numerator = numerator;         this->denominator = denominator;     }friend ostream& operator<<(ostream& out,rational &ob);     rational operator+(rational ro)...

UVA 10286(Geometry)Trouble with a Pentagon

ছবি
UVA 10286(Geometry): Solution: C++ Code: #include<iostream> #include<math.h> #include<cstdio> #define pi acos(-1) #define constf (cos(pi/20)+(sin(pi/20)*tan(3*pi/20))) using namespace std; int main(){     double P;     while(cin>>P){         printf("%.10lf\n",P*constf);     }return 0; }

UVA 10533(prime number)

Solution: #include <iostream> #include <vector> using namespace std; int main(){ vector<bool> prime(1000001,1); vector<int> digitPrime(1000001,0); int digitPrimeNum=0; prime[0]=0; prime[1]=0; for(int i=2;i<=1000000;i++){ if(prime[i]){ int temp=i,sum=0; while(temp){ sum+=(temp%10); temp/=10; }if(prime[sum]){ digitPrime[i]=++digitPrimeNum; } for(int j=i+i;j<=1000000;j+=i){ prime[j]=0; } } } int N; cin>>N; while(N--){ int t1,t2; cin>>t1>>t2; int result=0; while(t1<t2){ if(!digitPrime[t1]){ t1++; } if(!digitPrime[t2]){ t2--; } if(digitPrime[t2]&&digitPrime[t1]){ result=digitPrime[t2]-digitPrime[t1]; break; } } if(digitPrime[t1]){ result++; } cout<<result<<endl; }return 0; } /* Input: 3 10 20 10 100 100 10000 Output: 1 10 576 */

UVA 10474

UVA 10474: #include <iostream> #include <vector> #include <algorithm> using namespace std; int main(){ int N,Q,c=1; while(cin>>N>>Q&&(N||Q)){ cout<<"CASE# "<<c++<<':'<<endl; vector<int> vect(N); for(int i=0;i<N;i++){ cin>>vect[i]; } sort(vect.begin(),vect.end()); for(int i=0;i<Q;i++){ int s=0,e=N,a,q; cin>>q; int p=N,k=50; while(k--){ a=(s+e)/2; if(q==vect[a]){ if(p>a){ p=a; } }if(s==a||a==e){ if(p<N){ cout<<q<<" found at "<<p+1<<endl; }else{ cout<<q<<" not found"<<endl; }break; } else if(q>vect[a]){ s=a; }else if(q<=vect[a]){ e=a; } } } } return 0; }