Declaring certain elements as const in an array c++, sudoku solver [closed] - c++

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
Is it possible for me to take an existing array and make certain values (not all) constant? I'm trying to build a sudoku solver and my idea is to have the user enter values, so I would like to have those values remain constant as I change the empty spaces. Any tips or advice with the solver would also be appreciated. This is my first quarter working with c++. Thanks!

No. Const is essentially a compile-time idea. It's not something that can be toggled as a program is running.
If you need certain values to remain untouched while others are changed, then you need to put that into your data and logic. For instance, each value might have an associated boolean that indicates whether or not it can be changed. Then write your logic to respect that boolean.

Related

C++ the value of a variable in a string [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I want to make a function that has one parameter (a string that contains the name of a variable in my program) and returns the value that the variable stores.
Unfortunately, C++ doesn't provide a simple mechanism for reflection (the idea that the program can, at runtime, look up variable names by value or the like). You may need to consider using an alternate approach.
For example, you could make a std::unordered_map whose keys represent certain values that you'd like to look up and whose values are populated with the items you'd like to look up.
Hope this helps!

How do i use Qvarient in cpp for set functions [closed]

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 6 years ago.
Improve this question
I want to pass values from qml to set function written in Qt cpp, the values that will be passed is of different data types, example int or string, I will be writing only one set function in cpp which will take this values and return Qstring or int or double.How can I write a code for this.
C++ does know of two types:
QVariant
QJSValue
which might be the value, that you passed... That depends on you.
Both of them have various methods to test for their content, and to convert to this.
See the linked documentations for this.
You may even store the passed value as the corresponding type, without the need of conversion (up to the time, you need it for calculations in C++) It depends on, what you will do with it, to find the right choice.

Using a Linked List or Array for Monopoly? [closed]

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 8 years ago.
Improve this question
I'm making a Monopoly game for a school project, written in C++. The first thing I'm working on is implementing the board. It's intuitive to me that each tile will be an object holding information and functions and whatnot, but I cannot decide whether these should be contained in a linked list or array.
It made sense for a linked list because i could simply have the last tile point to the first, but it also seems more efficient to use an array since I can instantly access Tile[5] for example.
Can anybody clarify as to which would be better for this purpose?
It's a fixed size. That negates about 90% of the advantages of a linked list.
You will NEVER be accessing it sequentially (unless, instead of dice, everybody just moves one square each time), but always randomly. That's about 90% of the advantage of an array.
The one reason you cite for using a linked-list is trivially handled differently. (new_position = (current_position + roll) % 40;)
Therefore: You unquestionably want to use an array.

C++ take a user input as the number of dimensions an array has? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I can't seem to find anything regarding whether or not this is possible. Ideally I'd have someone input an integer like "4" and then it would make a 4-d array.
is this at all possible?
As explained in the Stack Overflow post, "Create an N dimensional array, where N is determined at runtime (C++)":
The dimensions of an array are part of the type, and the type must be known
at compile time.
Thus the programmer must specify the dimensions of the array before compile-time, not during run-time.
Type checking is typically one of the first operations a compiler does (it is specifically found in the semantic analysis portion of the compiler's control flow) to ensure the code received is free of simple programming errors (assignment/equivilance errors, etc).
Please let me know if you have any questions!

Count char occurs in string with length 10^200 [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I have a string on Linux standard terminal input. Its maximal length is 10^200 (as said in program specification). I have to count, how many "3" characters are inside it (occur in this string). I couldn't do that by for loop, because there is no so big variable type, which can be used as iterator. Is there any way to analyze so big strings?
Is there any way to analyze so big strings?
Not in this universe there is not. Such an entity cannot exist in this universe1 and that which does not exist, cannot be analyzed.
1 Current estimates of this universe's total number of particles particles are in the region of 1080.
As from your comment
The data source is standard terminal input.
Then you'll need a lot of monkeys to type this in.
Though you don't need to read in what's typed at once into a big string, but you can simply analyze char by char as typed. The std::istream::get(char_type& ch) method is suitable for doing so.