logic

Associative list in Prolog

半世苍凉 提交于 2019-12-11 01:13:37
问题 i m doing associative list in prolog i seen this topic but i dont understand the code. Associative Lists in Prolog For checking list is associative isn't enough do this: lists([_X, _Y]). lists([[H|_T]|L],[H|T]):- lists(L,T). Because for first /1 i check if have element in this way [a,3] and /2 take list of list [[a,4],[a,3]] in this way. so first pass call list/2 on [a,3], and check true for base case, and after call [a,4] and call true for base case too. I wrong something, but i don't see,

Infinite Loop when a character is entered [duplicate]

纵然是瞬间 提交于 2019-12-10 23:58:09
问题 This question already has answers here : Avoiding infinite loop when a char is enter in place of int (2 answers) Closed 3 years ago . I am trying to restrict the user to enter only '1' or '2'. int ch; do { cout<<"Enter: \n"; cin>>ch; switch(ch) { case 1: cout<<"1"; break; case 2: cout<<"2"; break; default: cout<<"Retry\n"; } }while(ch != 1 && ch != 2); When I enter any number other than 1 or 2, the program runs fine by asking user to retry, however when I enter a character, the program enters

C++ - How to hide other application's window

落爺英雄遲暮 提交于 2019-12-10 23:51:06
问题 I am trying to create a software(Qt/C++). In which I need a functionality that hiding other application windows based on their window titles. Hiding means invisible not minimize. Can any body say how to achieve this?. I am currently working on Windows platform. Note: If you provide a solution via Qt, it will give more comfort. Because it provides the platform independency. 回答1: For Windows, if you have an HWND to another application's window, you can call the ShowWindow function, like this:

R Tree With n Branches

帅比萌擦擦* 提交于 2019-12-10 22:12:25
问题 How can I generate a tree with n nodes, each of which have m number of children, with the condition that each child node is obtained by fun(parent)? I've gleaned some logic from this post, but I am stuck on how to generate up to n names, and also how to generate the functions for assigning newly generated children to their parents recursively. (insert utopian joke here) -Edit- I've attempted using TheTime's solution below, and this certainly answered this question. However, I didn't ask the

Java 2d array TicTacToe NumberFormat error [closed]

走远了吗. 提交于 2019-12-10 22:09:46
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 10 months ago . My method entreeIncorrecte is there to check for user input. If the value for ligne and colonne are anything other than "0", "1", "2" or "3", I want to print out that the user was incorrect and restart the loop for entreeIncorrecte . If I enter "e" and "3" for the row and column

prolog, copying lists

北慕城南 提交于 2019-12-10 17:42:20
问题 I am attempting to get my arms around some basic prolog but struggling a bit in the process. In specific - I am trying to get through a list of items and copy it, item by item into a new list. I can get it to reverse, but I am finding it trickier doing it without reversing. Ive been trying the following - copy(L,R) :- accCp(L,R). accCp([],R). accCp([H|T],R) :- accCp(T,H). When i run a trace on this - i can see the individual items being copied across, but they get 'lost', and dont form a

Largest product in a grid

亡梦爱人 提交于 2019-12-10 15:56:36
问题 I'm stuck with this problem. I do think I've got the right solution but when submitting it to the website, it does not accept it. I tried debugging it by printing all the possible combinations and they're all done (horizontally, vertically and diagonally). The array is filled correctly also. I checked it by printing it after. Do you know where the problem may be? Question What is the greatest product of four adjacent numbers in the same direction (up, down, left, right, or diagonally) in the

Runtime error with tinyXML element access

纵然是瞬间 提交于 2019-12-10 15:27:20
问题 yester day was my first attempt. I am trying to catch the variable "time" in the following "new.xml" file <?xml version="1.0" standalone=no> <main> <ToDo time="1"> <Item priority="1"> Go to the <bold>Toy store!</bold></Item> <Item priority="2"> Do bills</Item> </ToDo> <ToDo time="2"> <Item priority="1"> Go to the Second<bold>Toy store!</bold></Item> </ToDo> </main> Here is my code TiXmlDocument doc("new.xml"); TiXmlNode * element=doc.FirstChild("main"); element=element->FirstChild("ToDo");

Select rows after a row with a certain value

懵懂的女人 提交于 2019-12-10 15:22:12
问题 Hey again, im still getting a hang of Queries and stuff so please excuse all the frequent sql questions 8) Anyways im trying to select rows after a certain value. Dont understand? Ok this is how it actually looks. Table: messages +------------+-----------+---------+-------+---------------------------------------+----------------+------------------+ | message_id | thread_id | user_id | to_id | body | message_status | uid_sent_deleted | +------------+-----------+---------+-------+--------------

Prolog: simulate disjunctive facts

有些话、适合烂在心里 提交于 2019-12-10 15:16:46
问题 I've got a logic problem that I'd like to solve, so I thought, "I know, I'll try Prolog!" Unfortunately, I'm running into a brick wall almost immediately. One of the assumptions involved is a disjunctive fact; either A, B or C is true (or more than one), but I do not know which. I've since learned that this is something Prolog does not support. There's a lot of documentation out there that seems to address the subject, but most of it seems to immediately involve more intricate concepts and