From a3268742f3b30bdb8d12bf38b81b32212df731b7 Mon Sep 17 00:00:00 2001 From: faizan Ahamed Date: Tue, 21 Apr 2020 00:45:22 +0530 Subject: [PATCH 01/14] Create searching_of_element_in_dynamic_Array.cpp --- .../searching_of_element_in_dynamic_Array.cpp | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 dynamic_programming/searching_of_element_in_dynamic_Array.cpp diff --git a/dynamic_programming/searching_of_element_in_dynamic_Array.cpp b/dynamic_programming/searching_of_element_in_dynamic_Array.cpp new file mode 100644 index 000000000..23b2b1066 --- /dev/null +++ b/dynamic_programming/searching_of_element_in_dynamic_Array.cpp @@ -0,0 +1,67 @@ +/* +this program is use to find any elemet in any row with variable array size +aplication of pointer is use in it +important point start from here to: +the index value of array can be go to 1 to 100000 +check till array[1000] +end here +how to work example: +Question: +number of array 2 +quarry 3 +array 1 is {1 2 3 4 5} +array 2 is {6 7} +i) what is 2nd element in 1st array +ii) what is 1st element in 2nd array +iii) what is 5th element in 1st array +output: +Enter Number of array you want to Store : 2 +Enter Number of Question or Quary you want to do Related to Array : 3 +Enter number of element in 1 rows : 5 +Enter the element of Array 1 2 3 4 5 +Enter number of element in 2 rows : 2 +Enter the element of Array 6 7 +enter the number of row which element You want to find : 1 +enter the position of element which You want to find : 2 +The element is 2 +enter the number of row which element You want to find : 2 +enter the position of element which You want to find : 1 +The element is 6 +enter the number of row which element You want to find : 1 +enter the position of element which You want to find : 5 +The element is 5 +*/ +#include +int main() { +long long int r, mr = 0, x, q, i, z; +std::cout << "Enter Number of array you want to Store :"; +std::cin >> x; +std::cout << "Enter Number of Question or Quary you want to do Related to Array :"; +std::cin >> q; +//create a Array in run time because use can change the size of each array which he/she is going to store +//create a 2D array +int** ar = new int* [x](); +for (r = 0; r < x; r++) { +std::cout << "Enter number of element in " << r + 1 << " rows :"; +std::cin >> mr; +//creating a 1D array +int* ac = new int[mr](); +std::cout << "Enter the element of Array "; +for (i = 0; i < mr; i++) { +//entering the value of rows in array in Horizontal +std::cin >> ac[i]; +} +//Change the position of Array so that new arrays entery will be done +ar[r] = ac; +} +for (z = 0; z < q; z++) { +long int r1 = 0, q1 = 0; +std::cout << "enter the number of row which element You want to find :"; +std::cin >> r1; +r1 = r1 - 1; +std::cout << "enter the position of element which You want to find :"; +std::cin>> q1; +q1 = q1 - 1; +//use this to find desire position of element in desire array +std::cout <<"The element is "<< ar[r1][q1] < Date: Tue, 21 Apr 2020 01:03:38 +0530 Subject: [PATCH 02/14] Update searching_of_element_in_dynamic_Array.cpp --- .../searching_of_element_in_dynamic_Array.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/dynamic_programming/searching_of_element_in_dynamic_Array.cpp b/dynamic_programming/searching_of_element_in_dynamic_Array.cpp index 23b2b1066..d7799d37e 100644 --- a/dynamic_programming/searching_of_element_in_dynamic_Array.cpp +++ b/dynamic_programming/searching_of_element_in_dynamic_Array.cpp @@ -33,35 +33,36 @@ The element is 5 */ #include int main() { -long long int r, mr = 0, x, q, i, z; +int64_t r, mr = 0, x, q, i, z; std::cout << "Enter Number of array you want to Store :"; std::cin >> x; std::cout << "Enter Number of Question or Quary you want to do Related to Array :"; std::cin >> q; -//create a Array in run time because use can change the size of each array which he/she is going to store -//create a 2D array +// create a Array in run time because use can +// change the size of each array which he/she is going to store +// create a 2D array int** ar = new int* [x](); for (r = 0; r < x; r++) { std::cout << "Enter number of element in " << r + 1 << " rows :"; std::cin >> mr; -//creating a 1D array +// creating a 1D array int* ac = new int[mr](); std::cout << "Enter the element of Array "; for (i = 0; i < mr; i++) { -//entering the value of rows in array in Horizontal +// entering the value of rows in array in Horizontal std::cin >> ac[i]; } -//Change the position of Array so that new arrays entery will be done +// Change the position of Array so that new arrays entery will be done ar[r] = ac; } for (z = 0; z < q; z++) { -long int r1 = 0, q1 = 0; +int64_t r1 = 0, q1 = 0; std::cout << "enter the number of row which element You want to find :"; std::cin >> r1; r1 = r1 - 1; std::cout << "enter the position of element which You want to find :"; std::cin>> q1; q1 = q1 - 1; -//use this to find desire position of element in desire array +// use this to find desire position of element in desire array std::cout <<"The element is "<< ar[r1][q1] < Date: Tue, 21 Apr 2020 01:07:37 +0530 Subject: [PATCH 03/14] Update searching_of_element_in_dynamic_Array.cpp --- dynamic_programming/searching_of_element_in_dynamic_Array.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dynamic_programming/searching_of_element_in_dynamic_Array.cpp b/dynamic_programming/searching_of_element_in_dynamic_Array.cpp index d7799d37e..86243c9e7 100644 --- a/dynamic_programming/searching_of_element_in_dynamic_Array.cpp +++ b/dynamic_programming/searching_of_element_in_dynamic_Array.cpp @@ -36,7 +36,9 @@ int main() { int64_t r, mr = 0, x, q, i, z; std::cout << "Enter Number of array you want to Store :"; std::cin >> x; -std::cout << "Enter Number of Question or Quary you want to do Related to Array :"; +std::cout << "Enter Number of "; +std::cout<<"Question or Quary you "; +std::cout<<"want to do Related to Array :"; std::cin >> q; // create a Array in run time because use can // change the size of each array which he/she is going to store From db53fd1cf7b7061d509fc84690f17096f36ca622 Mon Sep 17 00:00:00 2001 From: faizan Ahamed Date: Tue, 21 Apr 2020 01:09:01 +0530 Subject: [PATCH 04/14] Update searching_of_element_in_dynamic_Array.cpp --- dynamic_programming/searching_of_element_in_dynamic_Array.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dynamic_programming/searching_of_element_in_dynamic_Array.cpp b/dynamic_programming/searching_of_element_in_dynamic_Array.cpp index 86243c9e7..436088aea 100644 --- a/dynamic_programming/searching_of_element_in_dynamic_Array.cpp +++ b/dynamic_programming/searching_of_element_in_dynamic_Array.cpp @@ -37,8 +37,8 @@ int64_t r, mr = 0, x, q, i, z; std::cout << "Enter Number of array you want to Store :"; std::cin >> x; std::cout << "Enter Number of "; -std::cout<<"Question or Quary you "; -std::cout<<"want to do Related to Array :"; +std::cout << "Question or Quary you "; +std::cout << "want to do Related to Array :"; std::cin >> q; // create a Array in run time because use can // change the size of each array which he/she is going to store From 15146a35fd5e98fb4f1eaefe4248f83efb3fa73f Mon Sep 17 00:00:00 2001 From: faizan Ahamed Date: Tue, 21 Apr 2020 01:12:58 +0530 Subject: [PATCH 05/14] Update searching_of_element_in_dynamic_Array.cpp --- dynamic_programming/searching_of_element_in_dynamic_Array.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dynamic_programming/searching_of_element_in_dynamic_Array.cpp b/dynamic_programming/searching_of_element_in_dynamic_Array.cpp index 436088aea..c13de8e06 100644 --- a/dynamic_programming/searching_of_element_in_dynamic_Array.cpp +++ b/dynamic_programming/searching_of_element_in_dynamic_Array.cpp @@ -63,7 +63,7 @@ std::cout << "enter the number of row which element You want to find :"; std::cin >> r1; r1 = r1 - 1; std::cout << "enter the position of element which You want to find :"; -std::cin>> q1; +std::cin >> q1; q1 = q1 - 1; // use this to find desire position of element in desire array std::cout <<"The element is "<< ar[r1][q1] < Date: Tue, 21 Apr 2020 01:18:18 +0530 Subject: [PATCH 06/14] Rename searching_of_element_in_dynamic_Array.cpp to searching_of_element_in_dynamic_array.cpp --- ...ynamic_Array.cpp => searching_of_element_in_dynamic_array.cpp} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename dynamic_programming/{searching_of_element_in_dynamic_Array.cpp => searching_of_element_in_dynamic_array.cpp} (100%) diff --git a/dynamic_programming/searching_of_element_in_dynamic_Array.cpp b/dynamic_programming/searching_of_element_in_dynamic_array.cpp similarity index 100% rename from dynamic_programming/searching_of_element_in_dynamic_Array.cpp rename to dynamic_programming/searching_of_element_in_dynamic_array.cpp From 52782f57f65ac1c92b2b465a661e5b295fff4e46 Mon Sep 17 00:00:00 2001 From: Faizan Ahamed Date: Tue, 21 Apr 2020 20:23:36 +0530 Subject: [PATCH 07/14] Update searching_of_element_in_dynamic_array.cpp --- .../searching_of_element_in_dynamic_array.cpp | 70 +++++++++++-------- 1 file changed, 39 insertions(+), 31 deletions(-) diff --git a/dynamic_programming/searching_of_element_in_dynamic_array.cpp b/dynamic_programming/searching_of_element_in_dynamic_array.cpp index c13de8e06..b4403d05c 100644 --- a/dynamic_programming/searching_of_element_in_dynamic_array.cpp +++ b/dynamic_programming/searching_of_element_in_dynamic_array.cpp @@ -1,37 +1,39 @@ /* -this program is use to find any elemet in any row with variable array size -aplication of pointer is use in it -important point start from here to: -the index value of array can be go to 1 to 100000 -check till array[1000] -end here -how to work example: -Question: -number of array 2 -quarry 3 -array 1 is {1 2 3 4 5} -array 2 is {6 7} -i) what is 2nd element in 1st array -ii) what is 1st element in 2nd array -iii) what is 5th element in 1st array -output: -Enter Number of array you want to Store : 2 -Enter Number of Question or Quary you want to do Related to Array : 3 -Enter number of element in 1 rows : 5 -Enter the element of Array 1 2 3 4 5 -Enter number of element in 2 rows : 2 -Enter the element of Array 6 7 -enter the number of row which element You want to find : 1 -enter the position of element which You want to find : 2 -The element is 2 -enter the number of row which element You want to find : 2 -enter the position of element which You want to find : 1 -The element is 6 -enter the number of row which element You want to find : 1 -enter the position of element which You want to find : 5 -The element is 5 +*this program is use to find any elemet in any row with variable array size +*aplication of pointer is use in it +*important point start from here to: +*the index value of array can be go to 1 to 100000 +*check till array[1000] +*end here +*how to work example: +**Question: +***number of array 2 +***quarry 3 +***array 1 is {1 2 3 4 5} +***array 2 is {6 7} +****i) what is 2nd element in 1st array +****ii) what is 1st element in 2nd array +****iii) what is 5th element in 1st array +*****output: +*****Enter Number of array you want to Store : 2 +*****Enter Number of Question or Quary you want to do Related to Array : 3 +*****Enter number of element in 1 rows : 5 +*****Enter the element of Array 1 2 3 4 5 +*****Enter number of element in 2 rows : 2 +*****Enter the element of Array 6 7 +*****enter the number of row which element You want to find : 1 +*****enter the position of element which You want to find : 2 +*****The element is 2 +*****enter the number of row which element You want to find : 2 +*****enter the position of element which You want to find : 1 +*****The element is 6 +*****enter the number of row which element You want to find : 1 +*****enter the position of element which You want to find : 5 +*****The element is 5 */ #include +// this is main fuction +// *** int main() { int64_t r, mr = 0, x, q, i, z; std::cout << "Enter Number of array you want to Store :"; @@ -44,12 +46,16 @@ std::cin >> q; // change the size of each array which he/she is going to store // create a 2D array int** ar = new int* [x](); +// this for loop is use for entering different variable size array +// *** for (r = 0; r < x; r++) { std::cout << "Enter number of element in " << r + 1 << " rows :"; std::cin >> mr; // creating a 1D array int* ac = new int[mr](); std::cout << "Enter the element of Array "; +// this for loop is use for storing values in array +// *** for (i = 0; i < mr; i++) { // entering the value of rows in array in Horizontal std::cin >> ac[i]; @@ -57,6 +63,8 @@ std::cin >> ac[i]; // Change the position of Array so that new arrays entery will be done ar[r] = ac; } +// this for loop is use for display result of querry +// *** for (z = 0; z < q; z++) { int64_t r1 = 0, q1 = 0; std::cout << "enter the number of row which element You want to find :"; From ae1c2a243fea3e650b53aef9ba7a6badfa9bbc0c Mon Sep 17 00:00:00 2001 From: Faizan Ahamed Date: Tue, 21 Apr 2020 21:30:57 +0530 Subject: [PATCH 08/14] Update searching_of_element_in_dynamic_array.cpp --- .../searching_of_element_in_dynamic_array.cpp | 89 ++++++++++--------- 1 file changed, 48 insertions(+), 41 deletions(-) diff --git a/dynamic_programming/searching_of_element_in_dynamic_array.cpp b/dynamic_programming/searching_of_element_in_dynamic_array.cpp index b4403d05c..840af3e66 100644 --- a/dynamic_programming/searching_of_element_in_dynamic_array.cpp +++ b/dynamic_programming/searching_of_element_in_dynamic_array.cpp @@ -32,47 +32,54 @@ *****The element is 5 */ #include + // this is main fuction // *** -int main() { -int64_t r, mr = 0, x, q, i, z; -std::cout << "Enter Number of array you want to Store :"; -std::cin >> x; -std::cout << "Enter Number of "; -std::cout << "Question or Quary you "; -std::cout << "want to do Related to Array :"; -std::cin >> q; -// create a Array in run time because use can -// change the size of each array which he/she is going to store -// create a 2D array -int** ar = new int* [x](); -// this for loop is use for entering different variable size array -// *** -for (r = 0; r < x; r++) { -std::cout << "Enter number of element in " << r + 1 << " rows :"; -std::cin >> mr; -// creating a 1D array -int* ac = new int[mr](); -std::cout << "Enter the element of Array "; -// this for loop is use for storing values in array -// *** -for (i = 0; i < mr; i++) { -// entering the value of rows in array in Horizontal -std::cin >> ac[i]; +int main() +{ + int64_t r, mr = 0, x, q, i, z; + std::cout << "Enter Number of array you want to Store :"; + std::cin >> x; + std::cout << "Enter Number of "; + std::cout << "Question or Quary you "; + std::cout << "want to do Related to Array :"; + std::cin >> q; + + // create a Array in run time because use can + // change the size of each array which he/she is going to store + // create a 2D array + int** ar = new int* [x](); + + // this for loop is use for entering different variable size array + // *** + for (r = 0; r < x; r++) { + std::cout << "Enter number of element in " << r + 1 << " rows :"; + std::cin >> mr; + // creating a 1D array + int* ac = new int[mr](); + std::cout << "Enter the element of Array "; + + // this for loop is use for storing values in array + // *** + for (i = 0; i < mr; i++) { + // entering the value of rows in array in Horizontal + std::cin >> ac[i]; + } + // Change the position of Array so that new arrays entery will be done + ar[r] = ac; + } + + // this for loop is use for display result of querry + // *** + for (z = 0; z < q; z++) { + int64_t r1 = 0, q1 = 0; + std::cout << "enter the number of row which element You want to find :"; + std::cin >> r1; + r1 = r1 - 1; + std::cout << "enter the position of element which You want to find :"; + std::cin >> q1; + q1 = q1 - 1; + // use this to find desire position of element in desire array + std::cout <<"The element is "<< ar[r1][q1] <> r1; -r1 = r1 - 1; -std::cout << "enter the position of element which You want to find :"; -std::cin >> q1; -q1 = q1 - 1; -// use this to find desire position of element in desire array -std::cout <<"The element is "<< ar[r1][q1] < Date: Tue, 21 Apr 2020 21:53:25 +0530 Subject: [PATCH 09/14] Update searching_of_element_in_dynamic_array.cpp --- .../searching_of_element_in_dynamic_array.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dynamic_programming/searching_of_element_in_dynamic_array.cpp b/dynamic_programming/searching_of_element_in_dynamic_array.cpp index 840af3e66..377d61428 100644 --- a/dynamic_programming/searching_of_element_in_dynamic_array.cpp +++ b/dynamic_programming/searching_of_element_in_dynamic_array.cpp @@ -64,10 +64,11 @@ int main() for (i = 0; i < mr; i++) { // entering the value of rows in array in Horizontal std::cin >> ac[i]; - } + } + // Change the position of Array so that new arrays entery will be done ar[r] = ac; - } + } // this for loop is use for display result of querry // *** @@ -81,5 +82,5 @@ int main() q1 = q1 - 1; // use this to find desire position of element in desire array std::cout <<"The element is "<< ar[r1][q1] < Date: Tue, 21 Apr 2020 21:55:39 +0530 Subject: [PATCH 10/14] Update searching_of_element_in_dynamic_array.cpp --- dynamic_programming/searching_of_element_in_dynamic_array.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dynamic_programming/searching_of_element_in_dynamic_array.cpp b/dynamic_programming/searching_of_element_in_dynamic_array.cpp index 377d61428..1a0a61a15 100644 --- a/dynamic_programming/searching_of_element_in_dynamic_array.cpp +++ b/dynamic_programming/searching_of_element_in_dynamic_array.cpp @@ -35,8 +35,7 @@ // this is main fuction // *** -int main() -{ +int main() { int64_t r, mr = 0, x, q, i, z; std::cout << "Enter Number of array you want to Store :"; std::cin >> x; From d2164cbe43cdf8c1d1a2507fa482c613a57b1347 Mon Sep 17 00:00:00 2001 From: Faizan Ahamed Date: Tue, 21 Apr 2020 22:09:03 +0530 Subject: [PATCH 11/14] Update searching_of_element_in_dynamic_array.cpp --- .../searching_of_element_in_dynamic_array.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/dynamic_programming/searching_of_element_in_dynamic_array.cpp b/dynamic_programming/searching_of_element_in_dynamic_array.cpp index 1a0a61a15..ff260bebd 100644 --- a/dynamic_programming/searching_of_element_in_dynamic_array.cpp +++ b/dynamic_programming/searching_of_element_in_dynamic_array.cpp @@ -43,12 +43,10 @@ int main() { std::cout << "Question or Quary you "; std::cout << "want to do Related to Array :"; std::cin >> q; - // create a Array in run time because use can // change the size of each array which he/she is going to store // create a 2D array int** ar = new int* [x](); - // this for loop is use for entering different variable size array // *** for (r = 0; r < x; r++) { @@ -57,7 +55,6 @@ int main() { // creating a 1D array int* ac = new int[mr](); std::cout << "Enter the element of Array "; - // this for loop is use for storing values in array // *** for (i = 0; i < mr; i++) { @@ -65,18 +62,17 @@ int main() { std::cin >> ac[i]; } - // Change the position of Array so that new arrays entery will be done + // Change the position of Array so that new arrays entery will be done ar[r] = ac; } - // this for loop is use for display result of querry // *** for (z = 0; z < q; z++) { int64_t r1 = 0, q1 = 0; - std::cout << "enter the number of row which element You want to find :"; + std::cout << "enter the number of row which element You want to find :"; std::cin >> r1; r1 = r1 - 1; - std::cout << "enter the position of element which You want to find :"; + std::cout << "enter the position of element which You want to find :"; std::cin >> q1; q1 = q1 - 1; // use this to find desire position of element in desire array From 6d1b9da209652a000fce9d1edab5ff76ed128d7b Mon Sep 17 00:00:00 2001 From: Faizan Ahamed Date: Tue, 21 Apr 2020 22:12:58 +0530 Subject: [PATCH 12/14] Update searching_of_element_in_dynamic_array.cpp --- dynamic_programming/searching_of_element_in_dynamic_array.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dynamic_programming/searching_of_element_in_dynamic_array.cpp b/dynamic_programming/searching_of_element_in_dynamic_array.cpp index ff260bebd..9c3f62578 100644 --- a/dynamic_programming/searching_of_element_in_dynamic_array.cpp +++ b/dynamic_programming/searching_of_element_in_dynamic_array.cpp @@ -61,8 +61,7 @@ int main() { // entering the value of rows in array in Horizontal std::cin >> ac[i]; } - - // Change the position of Array so that new arrays entery will be done + // Change the position of Array so that new arrays entery will be done ar[r] = ac; } // this for loop is use for display result of querry From 6a3c002977bb29de6758194485eeb6763f7f9563 Mon Sep 17 00:00:00 2001 From: Faizan Ahamed Date: Wed, 22 Apr 2020 11:02:19 +0530 Subject: [PATCH 13/14] Update dynamic_programming/searching_of_element_in_dynamic_array.cpp Co-Authored-By: Christian Clauss --- .../searching_of_element_in_dynamic_array.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dynamic_programming/searching_of_element_in_dynamic_array.cpp b/dynamic_programming/searching_of_element_in_dynamic_array.cpp index 9c3f62578..38ddc1336 100644 --- a/dynamic_programming/searching_of_element_in_dynamic_array.cpp +++ b/dynamic_programming/searching_of_element_in_dynamic_array.cpp @@ -68,10 +68,12 @@ int main() { // *** for (z = 0; z < q; z++) { int64_t r1 = 0, q1 = 0; - std::cout << "enter the number of row which element You want to find :"; + std::cout << "enter the number of row which element you want to \ + find :"; std::cin >> r1; r1 = r1 - 1; - std::cout << "enter the position of element which You want to find :"; + std::cout << "enter the position of element which you want to \ + find :"; std::cin >> q1; q1 = q1 - 1; // use this to find desire position of element in desire array From 21be8043ceaefdc8efec85dfa5b5e34906780a99 Mon Sep 17 00:00:00 2001 From: Faizan Ahamed Date: Wed, 22 Apr 2020 11:11:02 +0530 Subject: [PATCH 14/14] Update searching_of_element_in_dynamic_array.cpp --- .../searching_of_element_in_dynamic_array.cpp | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/dynamic_programming/searching_of_element_in_dynamic_array.cpp b/dynamic_programming/searching_of_element_in_dynamic_array.cpp index 38ddc1336..9ee48dded 100644 --- a/dynamic_programming/searching_of_element_in_dynamic_array.cpp +++ b/dynamic_programming/searching_of_element_in_dynamic_array.cpp @@ -62,21 +62,19 @@ int main() { std::cin >> ac[i]; } // Change the position of Array so that new arrays entery will be done - ar[r] = ac; + ar[r] = ac; + } + // this for loop is use for display result of querry + // *** + for (z = 0; z < q; z++) { + int64_t r1 = 0, q1 = 0; + std::cout << "enter the number of row which element you want to find :"; + std::cin >> r1; + r1 = r1 - 1; + std::cout << "enter the position of element which you want to find :"; + std::cin >> q1; + q1 = q1 - 1; + // use this to find desire position of element in desire array + std::cout <<"The element is "<< ar[r1][q1] <> r1; - r1 = r1 - 1; - std::cout << "enter the position of element which you want to \ - find :"; - std::cin >> q1; - q1 = q1 - 1; - // use this to find desire position of element in desire array - std::cout <<"The element is "<< ar[r1][q1] <