Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

12-05-2020 #128

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions Mitiushi Agarwal/11May/12May/assign2 q1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include<iostream>
using namespace std;
int main()
{
int a, b, c, i,lcm, count=0;
cout<<"Integer A:"<<endl;
cin>>a;
cout<<"Integer B:"<<endl;
cin>>b;
cout<<"Integer C:"<<endl;
cin>>c;
cout<<"numbers are:";
//brute force approach
for(i=1;i<=a;i++)
{
if(i%b==0 && i%c==0)
{
count++;
cout<<i<<" ";
}
}
cout<<endl<<"total numbers are "<<count;

Binary file added Mitiushi Agarwal/11May/12May/assign2 q1.exe
Binary file not shown.
22 changes: 22 additions & 0 deletions Mitiushi Agarwal/11May/12May/assign2q2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#include<iostream>
using namespace std;


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

int main()
{
int a,b,c;
cout<<"enter value 1:"<<endl;
cin>>a;
cout<<"enter value 2:"<<endl;
cin>>b;
c=gcd(a,b);
cout<<"Greatest common divisor is:"<<c;
}
Binary file added Mitiushi Agarwal/11May/12May/assign2q2.exe
Binary file not shown.
28 changes: 28 additions & 0 deletions Mitiushi Agarwal/11May/q1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include<iostream>
#include<vector>
using namespace std;
int main()
{
vector<int> ar;
ar.push_back(2);
ar.push_back(4);
ar.push_back(7);
ar.push_back(2);
ar.push_back(7);
ar.push_back(2);
ar.push_back(4);
int p=0,i;
cout<<"Array is:"<<endl;
for(i=0;i<ar.size();i++)
{
cout<<ar[i]<<" ";
}
cout<<endl;
for(i=0;i<ar.size();i++)
{
p=p^ar[i];
}
cout<<"the answer is "<<p<<endl;
}


Binary file added Mitiushi Agarwal/11May/q1.exe
Binary file not shown.
35 changes: 35 additions & 0 deletions Mitiushi Agarwal/11May/q2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
vector<int> ar;
/* ar.push_back(17);
ar.push_back(48);
ar.push_back(9);
ar.push_back(9);*/
ar.push_back(9);
ar.push_back(5);
ar.push_back(3);
int i,j,minx=INT_MAX,b;
cout<<"Array is:"<<endl;
for(i=0;i<ar.size();i++)
{
cout<<ar[i]<<" ";
}
cout<<endl;
for(i=0;i<ar.size();i++)
{
for(j=i+1;j<ar.size();j++)
{
b=ar[i]^ar[j];

if(b<minx)
{
minx=b;
}
}
}
cout<<"min ans is"<<minx;
}
Binary file added Mitiushi Agarwal/11May/q2.exe
Binary file not shown.
11 changes: 11 additions & 0 deletions Mitiushi Agarwal/11May/q3.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
int n,ans;
cout<<"enter number of bricks:"<<endl;
cin>>n;
ans=(-1+sqrt(1+8*n))/2;
cout<<"ans is"<<ans;
}
Binary file added Mitiushi Agarwal/11May/q3.exe
Binary file not shown.
43 changes: 43 additions & 0 deletions Mitiushi Agarwal/11May/q4.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include<iostream>
using namespace std;
int main()
{
int n,i,j;
int A[50][50]={0};
cout<<"enter range:"<<endl;
cin>>n;
for(i=0;i<n;i++)

{
A[i][0]=1;
}
for(i=1;i<n;i++){
for(j=1;j<n;j++){
cout<<A[i][j]<<" ";
}
cout<<endl;
}

for(i=1;i<n;i++){
for(j=1;j<n;j++){
if(i>=j){
if(i==j)
{
A[i][j]=A[i][j-1];
}
else
{
A[i][j]=A[i][j-1]+A[i-1][j];
}
}
}
}
cout<<endl<<"route map"<<endl;
for(i=0;i<n;i++){
for(j=0;j<n;j++){
cout<<A[i][j]<<" ";
}
cout<<endl;
}
cout<<"number of routes:"<<A[n-1][n-1];
}
Binary file added Mitiushi Agarwal/11May/q4.exe
Binary file not shown.