comment changed

This commit is contained in:
Anup Kumar Panwar 2016-08-30 15:01:33 +05:30
parent 5108393979
commit 4450f7780a
3 changed files with 75 additions and 14 deletions

View File

@ -1,21 +1,22 @@
//Bubble Sort //Insertion Sort
#include<iostream> #include<iostream>
using namespace std; using namespace std;
int main() int main()
{ {
int Array[6]; int n;
int Array[n];
cout<<"\nEnter any 6 Numbers for Unsorted Array : "; cout<<"\nEnter any 6 Numbers for Unsorted Array : ";
//Input //Input
for(int i=0; i<6; i++) for(int i=0; i<n; i++)
{ {
cin>>Array[i]; cin>>Array[i];
} }
//Sorting //Sorting
for(int i=1; i<6; i++) for(int i=1; i<n; i++)
{ {
int temp=Array[i]; int temp=Array[i];
int j=i-1; int j=i-1;
@ -29,7 +30,7 @@ int main()
//Output //Output
cout<<"\nSorted Array : "; cout<<"\nSorted Array : ";
for(int i=0; i<6; i++) for(int i=0; i<n; i++)
{ {
cout<<Array[i]<<"\t"; cout<<Array[i]<<"\t";
} }

66
Paranthesis Matching.cpp Normal file
View File

@ -0,0 +1,66 @@
#include<iostream>
#include<stdlib.h>
#include<string.h>
#include<stdio.h>
using namespace std;
char stack[100];
int top=0;
void push(char ch)
{
stack[top++]=ch;
}
char pop()
{
return stack[--top];
}
bool check(char x, char y)
{
if ( ( x=='(' && y==')' ) || ( x=='{' && y=='}' ) || ( x=='[' && y==']' ) || ( x=='<' && y=='>' ) )
{
return true;
}
else
{
return false;
}
}
int main()
{
char exp[100];
cout<<"Enter The Expression : ";
gets(exp);
for (int i = 0; i < strlen(exp); i++)
{
if (exp[i]=='(' || exp[i]=='{' || exp[i]=='[' || exp[i]=='<')
{
push(exp[i]);
//show();
}
else if (exp[i]==')' || exp[i]=='}' || exp[i]==']' || exp[i]=='>')
{
if(!check(pop(), exp[i]))
{
cout<<"\nWrong Expression";
exit(0);
}
}
}
if(top==0)
{
cout<<"Correct Expression";
}
else
{
cout<<"\nWrong Expression";
}
return 0;
}

View File

@ -65,7 +65,7 @@ int main()
int no; int no;
cout << "Enter number of discs : " ; cout << "\nEnter number of discs : " ;
cin >> no; cin >> no;
for (int i = no; i >0; i--) for (int i = no; i >0; i--)
@ -74,10 +74,7 @@ int main()
}; };
for (int i = (F.top)-1; i >=0; i--)
{
cout<<F.values[i]<<"\n";
}
show(); show();
@ -85,10 +82,7 @@ int main()
for (int i = (T.top)-1; i >=0; i--)
{
cout<<"\n"<<T.values[i];
}
return 0; return 0;
} }