Delete the least number of integers from a given set of integers so that the product of the remaining integers in the set is a perfect square. In case there is more than one solution then find the solution that gives the largest perfect square. Assume that each integer contains five or less number of digits. The total number of integers in the given set is twenty or less.
First line will be number of test cases
The input may contain multiple test cases.
For each test case there is a single input line. The line contains the given set of integers. The
For each test case there is only one output line. The line simply prints the integers to be deleted
inascending order. There are two special cases; print output for these cases as indicated below.
Case 1: No integer is to be deleted: Print 0as output.
Case 2: All integers are to be deleted: Print all integers inascending order.
Sorry, this site is not here to do people's homework for them. Please make an effort to do your own work, and if you have a specific question with the code you have written, then people will try to help you.
We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
Any failure of you will help you to learn what works and what don't, it is called 'trial and error' learning.
So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.
As programmer, your job is to create algorithms that solve specific problems and you can't rely on someone else to eternally do it for you, so there is a time where you will have to learn how to. And the sooner, the better.
When you just ask for the solution, it is like trying to learn to drive a car by having someone else training.
Creating an algorithm is basically finding the maths and make necessary adaptation to fit your actual problem.
The idea of "development" is as the word suggests: "The systematic use of scientific and technical knowledge to meet specific objectives or requirements." BusinessDictionary.com[^]
That's not the same thing as "have a quick google and give up if I can't find exactly the right code".
“Everything should be made as simple as possible, but no simpler.” Albert Einstein
Hello! I'm trying to browse a text file using CMFCEditBrowseCtrl (it is used in CFirstDialog Class) and use this file in another Dialog Class (named CSecondDialog Class). My problem is on how to save the filename retrieved from the CMFCEditBrowseCtrl when the CFirstDialog::OnEnChangeMfceditbrowse1() goes out of scope and then pass the filename to the CSecondDialog. Here is the code:
CStdioFile fileSource("here I need to put the filename retrieved from the previous dialog class", CFile::modeRead);
int num = 1;
The OnEnChangeMfceditbrowse1 method should store the file name in one of its object variables (or str) should be an object variable. The calling code can then capture that variable when the dialog returns.
You can now get and set the name from the class that holds the pointers to the dialogs. If both dialogs might not exist at the same time you have to store the file name in a member variable of that class (e.g. get the name when DoModal() returns).
Finally you need access to the upper class from CSecondDialog. If the upper class is the parent window, always of the same type, and has been passed as parent, you can use casting:
CParentOfDialogs *pParent = static_cast<CParentOfDialogs*>(GetParent());
// Use pParent here to get the stored name or retrieve it from the first dialog
CString strFileName = pParent->m_pFirstDialog->GetFileName();
Otherwise you have to use a member variable in your second dialog that holds a pointer to the upper class and is initalised upon dialog creation or using a set function.
There are also other solutions and variations of the above.
If both dialogs might not exist at the same time you have to store the file name in a member variable of that class (e.g. get the name when DoModal() returns).
The two dialogs do not exist at the same time, actually CSecondDialog gets on screen after I finish with CFirstDialog which goes out of scope. Could you explain me how to get the file name after DoModal() returns? Thank you in advance!
// TODO: Add your command handler code here
CInputDoc* pDoc = GetDocument();
CSecondDialog *pDlg = new CSecondDialog(this);
// TODO: Add your command handler code here
CMyDoc* pDoc = GetDocument();
Add a member variable to the first dialog (as already described) and to the parent window. Then get the file name from the dialog after calling:
// Get file name here before DialogWindow goes out of scope
m_strFileName = DialogWindow.GetFileName();
// Or (when DialogWindow.m_strFileName is public): //m_strFileName = DialogWindow.m_strFileName
If you create the second dialog from another class (not CInputView), you have to pass the name to the other class in a similar way.
Then set the file name before calling DoModal() of the second dialog:
// Pass file name before calling DoModal()
Could you please explain me how to store pointers to the dialogs when they are created so that I can get and set the name from the class that holds the pointers to the dialogs? I'm sorry for asking again but I got a little confused with this part.
What number will z in the sample code given below?
int z, x=5, y= -10, a=4, b=2;
z=x++ - --y *b/a;
Can anyone please solve it and explain the precedence. i am not getting right answer. my answer is 2.5. but it is wrong. i am struggling in it. kindly solve it and explain. Thanks in advance.
The first step is inserting parentheses according to the predence and order:
z = (x++) - (((--y) * b) / a);
Then replace the variables with their values:
z = (5++) - (((--(-10)) * 2) / 4);
Now solve step by step but observe the special handling of the postfix operator which will return a temporary copy that contains the value before the operation (that means x will be changed but the initial value of 5 is used for the calculation). Observe also that results might get rounded wirh integer arithmetic:
z = (5) - ((-11 * 2) / 4);
z = 5 - (-22 / 4);
// The remaining steps are left to your exercise
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle