formatting source-code for 153fb7b8a5

This commit is contained in:
github-actions
2020-05-30 04:02:09 +00:00
parent 92fe9495ec
commit 8a2de9842b
175 changed files with 1671 additions and 3460 deletions

View File

@@ -28,13 +28,10 @@ using namespace std;
// }
//}
int Knapsack(int capacity, int n, int weight[], int value[])
{
int Knapsack(int capacity, int n, int weight[], int value[]) {
int res[20][20];
for (int i = 0; i < n + 1; ++i)
{
for (int j = 0; j < capacity + 1; ++j)
{
for (int i = 0; i < n + 1; ++i) {
for (int j = 0; j < capacity + 1; ++j) {
if (i == 0 || j == 0)
res[i][j] = 0;
else if (weight[i - 1] <= j)
@@ -48,20 +45,17 @@ int Knapsack(int capacity, int n, int weight[], int value[])
// cout<<"\n";
return res[n][capacity];
}
int main()
{
int main() {
int n;
cout << "Enter number of items: ";
cin >> n;
int weight[n], value[n];
cout << "Enter weights: ";
for (int i = 0; i < n; ++i)
{
for (int i = 0; i < n; ++i) {
cin >> weight[i];
}
cout << "Enter values: ";
for (int i = 0; i < n; ++i)
{
for (int i = 0; i < n; ++i) {
cin >> value[i];
}
int capacity;