From cfd3db11754feae0be9f83768edcdcaf47221a1b Mon Sep 17 00:00:00 2001 From: Yudi2k <65284448+Yudi2k@users.noreply.github.com> Date: Wed, 13 May 2020 15:45:45 +0530 Subject: [PATCH 1/2] Add files via upload --- q1.cpp | 28 ++++++++++++++++++++++++++++ q2.cpp | 35 +++++++++++++++++++++++++++++++++++ q3.cpp | 11 +++++++++++ q4.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 117 insertions(+) create mode 100644 q1.cpp create mode 100644 q2.cpp create mode 100644 q3.cpp create mode 100644 q4.cpp diff --git a/q1.cpp b/q1.cpp new file mode 100644 index 0000000..e30ba63 --- /dev/null +++ b/q1.cpp @@ -0,0 +1,28 @@ +#include +#include +using namespace std; +int main() +{ + vector 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:"< +#include +#include +using namespace std; +int main() +{ + vector 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:"< +#include +using namespace std; +int main() +{ + int n,ans; + cout<<"enter number of bricks:"<>n; + ans=(-1+sqrt(1+8*n))/2; + cout<<"ans is"< +using namespace std; +int main() +{ + int n,i,j; + int A[50][50]={0}; + cout<<"enter range:"<>n; + for(i=0;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< Date: Thu, 14 May 2020 16:15:14 +0530 Subject: [PATCH 2/2] Add files via upload --- 12 may/ass2 q1.cpp | 23 +++++++++++++++++++++++ 12 may/ass2 q2.cpp | 22 ++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 12 may/ass2 q1.cpp create mode 100644 12 may/ass2 q2.cpp diff --git a/12 may/ass2 q1.cpp b/12 may/ass2 q1.cpp new file mode 100644 index 0000000..1061862 --- /dev/null +++ b/12 may/ass2 q1.cpp @@ -0,0 +1,23 @@ +#include +using namespace std; +int main() +{ + int a, b, c, i,lcm, count=0; + cout<<"Integer A:"<>a; + cout<<"Integer B:"<>b; + cout<<"Integer C:"<>c; + cout<<"numbers are:"; + //brute force approach + for(i=1;i<=a;i++) + { + if(i%b==0 && i%c==0) + { + count++; + cout< +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:"<>a; + cout<<"enter value 2:"<>b; + c=gcd(a,b); + cout<<"Greatest common divisor is:"<