Anonymous
Or memoization.
yeah "top down" dp
Shruti Debnath 376 Cse 25
Anonymous
Any solution for this? Thank you!
Check your system load. Or better change your system.
Anonymous
https://pastebin.com/cvuT7NV6 Can someone help me out in finding the error? It's the classical 0/1 knapsack, I implemented with memoization - the answer isn't getting displayed :/
Anonymous
Anonymous
Nope, simple one
Memset again with -1????
Anonymous
Memset again with -1????
I tried without it too xD
Anonymous
Memset again with -1????
fr2(i, 0, n, 1) { fr2(j, 0, W, 1) dp[i][j] = -1; }
Anonymous
BTW, I used memset on similar problems and it worked like a charm :/
Anonymous
Your DP equation looks fine too.
yeah i formed the recurrence wrt to the options, but idk what the error is still tryna figure it out
Anonymous
Your DP equation looks fine too.
okay it's working used memset itself btw xD
Anonymous
What was the issue
I had to use an additional space of n+1, W+1 since I was starting with 1 and the last index, that's the result would be at the dp[n][W]
NAM3L3SS
Hey programmers so am new at c++ trying to do a basic calculator using classes and objects Wrote my program wanted to like bring results of a specific method if called upon like if addition is called it brings the results of addition buhh kinda stuck here seems like it can't compile from their 👇 #include <iostream> using namespace std; class Calculator { public: double sum,sub,mult,div,mod; int num1,num2; void Addition(),Subtraction(),Multiplication(),Division(),Modulas() { cout<<"Enter the first number:"<<endl; cin>>num1; cout<<"Enter the second number:"<<endl; cin>>num2; sum = num1+num2; sub = num1-num2; mult = num1*num2; div = num1/num2; } void results() { if(Addition){ cout<<"The Sum of the first and second number is"<<sum<<endl; } } }; int main() { return 0; }
NAM3L3SS
So far that can't compile
NAM3L3SS
is it possible the line, void addition(), subtraction() ..... { body } anyone?
Seemed to compile when i tried it before adding the Void results()..
NAM3L3SS
Wanted to bypass the repeated asking of input on each void that's why i did that
𝘼𝙗𝙙𝙤
hello this function can't run in my Ide it keeps showing wrong : fgets(name, 20 , stdin ) ;
𝘼𝙗𝙙𝙤
the error showing is that stdin needs to be declared at first , anyone
S__R
what is the diffrence between sort and stable_sort i am getting same result in both
S__R
stable_sort(begin(arr), end(arr), x{ return abs(a - x) < abs(b - x); }); can someone explain this what that [x] means here
Ravi
if we want to keep the order of the elements as it is then we should use stable sort
Ravi
stable_sort(begin(arr), end(arr), x{ return abs(a - x) < abs(b - x); }); can someone explain this what that [x] means here
I dont find [x] but i think I got your point, it is for lambda expressions, You must refer Lambda expressions in sorting algorithms on google, you will understand in better way. They allows us to perform the sort as we want, like odds should be come first or something else you wnnt.
Shourya
is it possible the line, void addition(), subtraction() ..... { body } anyone?
Strange ..Don't know what he is trying to do ..But sure it compiles may be because of , evaluation rules and considers last function as member...
Anonymous
Hey
Anonymous
I started today with C
𝘼𝙗𝙙𝙤
hello this function can't run in my Ide it keeps showing wrong : fgets(name, 20 , stdin ) ;
the solution to this issue is that the code #include <stdio.h> and #include<stdlib.h> should be added
Shvmtz
#include <iostream> int main() { std::string input = "nitin"; unsigned inputLength = input.length(); for (unsigned i = 0; i < inputLength; i++) { for (unsigned j = i + 1; j <= inputLength; j++) { std::string subStringInput = input.substr(i, j); std::cout << subStringInput << std::endl; } } std::cin.get(); } Output: n ni nit niti nitin it iti itin itin tin tin tin in in n What is wrong in this code ? This does not print all the substrings of the string.
Ravi
input.substr(i,j-i)
Anonymous
J
Muhammad sanusi
I’m a beginner
Muhammad sanusi
I want know more about c/c++ programming
Brock Lesnar
Anyone have best book of c++
Brock Lesnar
For bigner
A
Thank you 😊
꧁༒𝐀𝐡𝐦𝐚𝐝༒꧂
@𝑺𝒐𝒃𝒌𝒂
Teatro
Anyone has a gitlab account? I need add 1 member to my project and all you have to do is upload something at gitAhead Its for school 🙏
Anonymous
How to empty a variable??
Pavel
How to empty a variable??
What is the type of the variable? And what do you mean by "empty"?
Anonymous
Hanz
Integer, i mean to delete the value inside it
Why do you need this? You can just assign it with the new value or leave it as it is
Hanz
Or you want to free it from memory?
不要惹胖虎
Hello, everyone, I want to ask a question. Is there a class like alarm, kill in the boost library? I want to write a program for event-based communication between processes based on boost library
Anonumous
I can't run my c program in my visual studio...did all the steps installing gcc correctly...🥺. Any help?
Anonumous
Watch some video on YouTube
Same error coming...trying...else using dev c only....
Anonumous
Problems solved.....many videos hv diffrnt way to compile it's c program in visual studio.....
Frey🏴‍☠️
Same error coming...trying...else using dev c only....
what's the Error showing when you try to run the code
Santee
hello
Anonymous
Is there someone interested to do some freelance work today? It is related to C/C++ maybe someone want to give it a shot, will just fix part if the code that throws errors and exceptions
Nils
Send me the code, will get into it asap
Anonymous
Awesome! Can I dm you @tuxifan ?
Nils
Awesome! Can I dm you @tuxifan ?
Will read it when I got time
Nils
Going on a travel
Binesh
#include<iostream> int main() { int limit; std::cout << "\nEnter the score\t:"; std::cin >> limit; int pc = 0, user = 0; do { label: int random = 1 + (rand() % 3); int button, choose; std::cout << "\n****ENTER YOUR CHOICE****\n 1. ROCK \n 2. PAPER \n 3.SCISSOR\n"; std::cin >> choose; if (random == choose) { std::cout << "\n!!!![SAME CHOICE]!!!!"; goto label; } if (random < choose) { if ((random + choose) == 4) { std::cout << "\n\n PC SCORED\t:\t" << ++pc; continue; } std::cout << "\n\nUSER SCORED\t:\t" << ++user; } if (random > choose) { if ((random + choose) == 4) { std::cout << "\n\n USER SCORED\t:\t" << ++user; continue; } std::cout << "\n\nPC SCORED\t:\t" << ++pc; } } while ((pc != limit) && (user != limit)); if (pc == limit) std::cout << "\n\n!!!!PC WINS!!!!"; else std::cout << "\n\n!!!!USER WINS!!!!"; return 0; }
Binesh
pls review the code
Binesh
pls review the code
https://pastebin.com/E6jV3tRA
Ishank
Which is the best book for c++
Pradevel (Pratyush)
Anonymous
/get cbook
Anonymous
/get c++book
Anonymous
/get c++book
Dude. Did you even check the stackoverflow link above?
Anonymous
No
Anonymous
No
Check it. There is a link to C++ books in that discussion itself.
Anonymous
/get india
Anonymous
/get imhacker
Anonymous
/get googleit