style: format code

This commit is contained in:
yanglbme
2019-08-21 10:10:08 +08:00
parent abc0d365de
commit 69ddc9fc52
101 changed files with 3154 additions and 2984 deletions

View File

@@ -1,7 +1,8 @@
//Program to calculate length of longest increasing subsequence in an array
#include <bits/stdc++.h>
using namespace std;
int LIS(int a[],int n){
int LIS(int a[], int n)
{
int lis[n];
for (int i = 0; i < n; ++i)
{
@@ -11,28 +12,28 @@ int LIS(int a[],int n){
{
for (int j = 0; j < i; ++j)
{
if(a[i]>a[j] && lis[i]<lis[j]+1)
if (a[i] > a[j] && lis[i] < lis[j] + 1)
lis[i] = lis[j] + 1;
}
}
int res = 0;
for (int i = 0; i < n; ++i)
{
res = max(res,lis[i]);
res = max(res, lis[i]);
}
return res;
}
int main(int argc, char const *argv[])
{
int n;
cout<<"Enter size of array: ";
cin>>n;
cout << "Enter size of array: ";
cin >> n;
int a[n];
cout<<"Enter array elements: ";
cout << "Enter array elements: ";
for (int i = 0; i < n; ++i)
{
cin>>a[i];
cin >> a[i];
}
cout<<LIS(a,n)<<endl;
cout << LIS(a, n) << endl;
return 0;
}