diff --git a/TargetSum.cpp b/TargetSum.cpp new file mode 100644 index 0000000..39ce350 --- /dev/null +++ b/TargetSum.cpp @@ -0,0 +1,167 @@ +#include +#include +#include +using namespace std; +//int secondlargest(vector v) //part of question +//{ //2 3 5 7 6 1 +// int maxindex=0; +// for(int i=0;i v[maxindex] ) +// { +// maxindex=i; +// } +// } +// return maxindex; +//} +int main() +{ +// cout<<"Find the total number of pair in the given array whose sum is equal to given x"< v(5); +// for(int i=0;i>v[i]; +// } +// int targetsum; +// cout<<"Enter the traget sum:"<>targetsum; +// int count=0; //to count no of pairs +// for(int i=0;i v(6); +// for (int i=0;i>v[i]; +// } +// int targetsum; +// cout<<"Enter the target sum:"<>targetsum; +// +// //for output +// int count=0; +// for (int i=0;i v(7); +// for(int i=0;i>v[i]; +// } +// +// for (int i=0;i v(6); +// for(int i=0;i>v[i]; +// } +// +// int largestElement=secondlargest(v); +//// v[largestElement]=-1; +// int Lelement=v[largestElement]; +// for(int i=0;i>n; +// +// cout<<"Rotate a given array n by k step where k is non negative integers note k can be greater then n as n is zie of arraya:"< v(n); +// for(int i=0;i>v[i]; +// } +// int k; +// cout<<"Enter your k step:"<>k; +// +// k=k%5; //becauce k can be greater then n and after 5 step we are getting back again same array. +// +// int newarray[5]; +// int j=0; +// for(int i=n-k;i>n; +// cout<<"Rotate a given array n by k step where k is non negative integers note k can be greater then n as n is zie of arraya:"< v(n); +// for(int i=0;i>v[i]; +// } +// int k; +// cout<<"Enter your k step:"<>k; +// k=k%v.size(); //becauce k can be greater then n and after 5 step we are getting back again same array. +// +// reverse (v.begin(), v.end()); +// reverse (v.begin(),v.begin()+k); +// reverse (v.begin()+k,v.end()); +// +// for(int i=0;i