Merge branch 'master' into master

This commit is contained in:
Ashwek Swamy
2019-02-09 15:53:03 +05:30
committed by GitHub
9 changed files with 76 additions and 42 deletions

View File

@@ -85,6 +85,7 @@ int main()
cout<<"\n2. Delete";
cout<<"\n3. Search";
cout<<"\n4. Print";
cout<<"\n0. Exit";
cout<<"\n\nEnter you choice : ";
cin>>choice;
switch (choice)
@@ -98,7 +99,8 @@ int main()
case 3 : cout<<"\nEnter the element to be searched : ";
cin>>x;
search(x); break;
case 4 : show(); break;
case 4 : show();
cout<<"\n"; break;
}
}
while(choice!=0);

View File

@@ -1,17 +1,24 @@
#include<iostream>
// This function convert decimal to binary number
//
#include <iostream>
using namespace std;
int main(){
int number;
cout <<"Enter number to find its binary : ";
cin>>number;
int remainder,binary=0,var=1;
do{
remainder = number%2;
number /= 2;
binary += (remainder*var);
var *= 10;
}while(number>0);
cout<<binary;
int main()
{
int number;
cout << "Enter a number:";
cin >> number;
int remainder, binary = 0, var = 1;
do {
remainder = number % 2;
number = number / 2;
binary = binary + (remainder*var);
var = var * 10;
} while (number>0);
cout << "the binary is :";
cout << binary;
cout << endl;
return 0;
}

View File

@@ -30,7 +30,7 @@ int editDist(string str1, string str2, int m, int n) {
//If last characters are same then continue
//for the rest of them.
if(str1[m-1] == str2[n-2])
if(str1[m-1] == str2[n-1])
return editDist(str1, str2, m-1, n-1);
//If last not same, then 3 possibilities
@@ -63,7 +63,7 @@ int editDistDP(string str1, string str2, int m, int n) {
//If character same. Recur for remaining
else if(str1[i-1] == str2[j-1])
dp[i][j] == dp[i-1][j-1];
dp[i][j] = dp[i-1][j-1];
else
dp[i][j] = 1 + min(dp[i][j-1],//Insert
@@ -80,8 +80,8 @@ int main() {
string str1 = "sunday";
string str2 = "saturday";
cout << editDist(str1, str1, str1.length(), str2.length()) << endl;
cout << editDistDP(str1, str1, str1.length(), str2.length()) << endl;
cout << editDist(str1, str2, str1.length(), str2.length()) << endl;
cout << editDistDP(str1, str2, str1.length(), str2.length()) << endl;
return 0;
}

View File

@@ -2,6 +2,7 @@
and this sum turns out to be 1 */
#include <iostream>
using namespace std;
int main()
{
int n,k,s=0,d;
@@ -23,4 +24,5 @@ int main()
cout << n << " is a happy number" << endl;
else
cout << n << " is not a happy number" << endl;
return 0;
}

View File

@@ -81,5 +81,5 @@ int main()
cout << n << " th Fibonacci is \n";
fib_Accurate(n);
return 0;
return 0;
}

View File

@@ -8,7 +8,7 @@ How you can contribute? See this small guide.
* Use the directory structure of the repository.
* Please describe your pull requests.
* Don't use **bits/stdc++.h** because this is quite Linux specific and slow down the compiler process.
* Put in comments in your code.
* Avoid **struct** uses instead the **class** keyword.
* Add some test cases in the main-function.
* Don't use **bits/stdc++.h** because this is quite Linux specific and slows down the compiler process.
* Put comments in your code.
* Avoid **struct**. Instead use the **class** keyword.
* Add some test cases in the main-function.

View File

@@ -1,35 +1,55 @@
//Bubble Sort
#include<iostream>
#include<vector>
using namespace std;
int main(){
int n, temp;
cout<<"Enter size of Array = ";
int main()
{
int n;
short swap_check=0;
cout << "Enter the amount of numbers to sort: ";
cin >> n;
int *Array = new int[n];
cout<<"\nEnter any " <<n <<" Numbers for Unsorted Array :\n";
vector<int> numbers;
cout << "Enter " << n << " numbers: ";
int num;
//Input
for(int i=0; i<n; i++){
cout<<"value " <<(i+1) <<" = ";
cin>>Array[i];
//Input
for(int i=0; i<n; i++)
{
cin >> num;
numbers.push_back(num);
}
//Bubble Sorting
for(int i=n; i>0; i--){
for(int j=0; j<i; j++){ // Array[i..n] is already sorted
if(Array[j]>Array[j+1]){
temp=Array[j];
Array[j]=Array[j+1];
Array[j+1]=temp;
for(int i=0; i<n; i++)
{
swap_check=0;
for(int j=0; j<n-1-i; j++)
{
if(numbers[j]>numbers[j+1])
{
swap_check=1;
swap(numbers[j], numbers[j+1]);
}
}
if(swap_check == 0)
{
break;
}
}
//Output
cout<<"\nSorted Array : ";
for(int i=0; i<n; i++)
cout<<Array[i]<<"\t";
return 0;
for(int i=0; i<numbers.size(); i++)
{
if(i != numbers.size() -1)
{
cout << numbers[i] << ", ";
}else
{
cout << numbers[i] << endl;
}
}
return 0;
}

View File

@@ -6,8 +6,10 @@ using namespace std;
int main()
{
int n;
cout<<"\nEnter the length of your array : ";
cin>>n;
int Array[n];
cout<<"\nEnter any 6 Numbers for Unsorted Array : ";
cout<<"\nEnter any "<<n<<" Numbers for Unsorted Array : ";
//Input
for(int i=0; i<n; i++)
@@ -34,5 +36,6 @@ int main()
{
cout<<Array[i]<<"\t";
}
return 0;
}

0
s[i]
View File