|
Sounds like a homework assignment and you are using native C++ (not C++/CLI). Since you can not check the array that has the numbers randomly placed without repeats. My suggested solution still stands with a modification. If the number range is 0 through 8, create a boolean array that holds 9 boolean numbers set to false. When your "srand function expression" creates a random number, check it against the array using its index. If the result is false, add the number to the random arranged array and set the indexed cell to true.
Think of your randomly arranged array as a shopping cart, and your shopping list is a list of numbers to be found and placed in the shopping cart. As you place the number in the cart, you scratch the number out so that you won't place that number in the cart again.
I gave you too much. If you can not figure out what I gave you. You need to review what you have not learned well.
-- modified at 9:00 Saturday 18th February, 2006
|
|
|
|
|
TBD
modified 28-Jan-14 19:19pm.
|
|
|
|
|
Ever heard about a nice thing called google ?
|
|
|
|
|
|
Hello people.
like Windows::Forms::Form->Controls holds the control collection. I need to know what controls lies on another application.
Any Idia ?
|
|
|
|
|
Nevermind. I found the answer. It's two APIs:
EnumChildWindow and RealGetWindowClass.
|
|
|
|
|
Thanks guys, i managed finally to do the program!
|
|
|
|
|
|
The question is that i have almost no idea how to do it. this is my second semester in c++. So i'd like just to give me an idea what to include in my functions or just the way of thought i have to follow. I'm definetely not asking for the source code or for someone else to do it for me. Just the way i have to think...
sorry, i didn't understand what do you mean about the [^]
chrizpl
|
|
|
|
|
chrizpl wrote: i have almost no idea how to do it
how to do what ??
chrizpl wrote: So i'd like just to give me an idea what to include in my functions
all demends on what you want to achieve, but here again, explain the 1st point.
chrizpl wrote: i didn't understand what do you mean about the [^]
did you click on the link and read the linked post ??
TOXCCT >>> GEII power [toxcct][VisualCalc 2.24][3.0 soon...]
|
|
|
|
|
Ok, i'll try to be as more specific i can.
When running the program the 1st time will appear on the screen a grid with numbers from 1-8 randomly. The user what have to do is to solve the puzzle, putting the numbers in ascending using either the arrows keys, either other keys which we'll define. Each time the user makes a move, a new grid will appeared on the screen.
My questions are:
1)Ok, i have to use a 2-d (3x3)array of type int and fill it with the numbers (let's say using rand()). But what about the element which has to be empty? I tried it and the compiler put a random number in the element which i didn't specify a value. So what i have to do in order to stay blank and recognize it as black?
2)i understand that i must use a function which will identify the legal moves that the user is able to do. But how? Is there a way to have direct access on the grid?
3)how the program will understand that the grid has been solved? the exercice was saying that numbers could be of the form 1 2 3
4 5 6
7 8
or of 1 2 3
8 4
7 6 5 .....
That's for now, i hope i wrote them in the proper way
thanks
chrizpl
|
|
|
|
|
1) Use 0 or -1 to indicate that the cell is empty. It's up to your program to recognize it as an empty cell
2) I don't get you here, what is the problem ? A legal move is I suppose when you move a cell with a number into the empty cell. So, just detect that a cell with a number is selected and that the destination cell is the empty one. Access to the grid will depend of your program architecture
3) What you can do is whenever a cell has been moved, check how your grid looks like and if it matches the solution, then you won the game
|
|
|
|
|
Today,I saw the macro Base_Offse from the book named essentials of COM.But,I can't understand it.please explain it in detail.Thank you!
The macro definition:
#define BASE_OFFSET(ClassName, BaseName) \
(DWORD(static_cast<basename*>(reinterpret_cast<classname*>\
(0x10000000))) - 0x10000000)
|
|
|
|
|
if it is documented, then trust it.
if it is not, then maybe it is for internal use, so, not for you...
TOXCCT >>> GEII power [toxcct][VisualCalc 2.24][3.0 soon...]
|
|
|
|
|
Hi All,
I have a small problem that I'm unable to zoom in on my Picturebox. Im using Managed C++
int zoomFactor = 2;
System::Drawing::Rectangle rectangleToZoom; //= gcnew System::Drawing::Rectangle();
rectangleToZoom.X = 200;
rectangleToZoom.Y = 100;
rectangleToZoom.Width = 100;
rectangleToZoom.Height = 100;
System::Drawing::Bitmap ^map = gcnew System::Drawing::Bitmap(this->viewPictureE->Image);
System::Drawing::Bitmap ^imageToZoom = map->Clone(rectangleToZoom, System::Drawing::Imaging::PixelFormat::DontCare);
System::Drawing::Bitmap ^zoomImage =gcnew System::Drawing::Bitmap( rectangleToZoom.Width * zoomFactor,rectangleToZoom.Height * zoomFactor);
System::Drawing::Graphics ^ graphics = System::Drawing::Graphics::FromImage(zoomImage);
System::Drawing::Rectangle ^rectangleOfTarget = gcnew System::Drawing::Rectangle(0,0,zoomImage->Width,zoomImage->Height);
graphics->DrawImage(imageToZoom,rectangleToZoom);
It compiles But it doesnt actually zoom in. It does nothing. I have the mouse event handler set to the function.
Can someone see anythin wrong with my code.
any help will be appreciated
Thanks
Jonno
-- modified at 1:47 Friday 17th February, 2006
|
|
|
|
|
Is it possible in any way to make native types visible outside the assembly? I have a mixed assembly as a .dll file and want some of the native classes in this assembly to be consumed by other C++/CLI projects... The artciles in MSDN are very fuzzy as far as this problem is concerned, so I'm not sure if I can make it. Normally, even when I use the "public" keyword, the only classes visible when I reference my .dll in other projects are the managed ones.
---Kordzik---
|
|
|
|
|
Yes, only managed class (not native) will be visible. You have to wrap the native classes with managed classes.
-- modified at 19:02 Thursday 16th February, 2006
|
|
|
|
|
Ok thnx now it's all clear, although it doesn't make my life easier...
|
|
|
|
|
Hello,
I have an MC++ class exposing a COM interface ISrv. MC++ class also has a source interface, ISrc.
ISrv has below method:
void AttachSink( [MarshalAs(UnManagedType::IUnknown)]Object* pSrcUnk,
Int32 *pError, Int32* pState);
I have MFC sink class (derived from CCmdTarget) and implements ISrc interface.
Native C++ application instantiates this sink class and passes the sink object to MC++ by calling above method.
During CTRL+C operation, when sink object is destroyed , CCmdTarget throws an assertion at line:
ASSERT(m_dwRef <= 1)
In the debugger I found m_dwRef as 3. If this call is commnented then the assertion doesn't fail.
Debugging info:
I kept some "cout" statements within Sink class in side overridden method, QueryInterface().
I observed that QI was called 3 times in excess when the above method was called in my native application.
Actually, I call QI only once (right after Sink object instantiation) to retrieve ISrc interface.
Therefore, I presumed that it may be CCW invoking QI those many times and incrementing reference count. Is this correct?
Can you please let me know how to get around this problem of incorrect reference count?
I observed this problem only when this method was called. I call many other methods of MC++ class. But those methods do not take pointer to IUnknown as their parameter.
Does CCW behave different when IUnknown * is marshalled.
Is it likely that it does auto increment of reference count?
PLEASE SEE: I called Marshal::ReleaseCOMObject() in MC++ class and it returned reference count as 1. However, during the destruction of Sink object, ASSERT still popsup.
Looking forward your response....
Thank you and best Regards,
-- modified at 14:44 Thursday 16th February, 2006
|
|
|
|
|
Ok........how do I even begin this? What should the header file look like? Then how do I put everything together in the cpp file? I need HELP!!!
You are to create a student record object. The info about the student is below:
Last Name
First Name
Social Security Number (Format: XXX-XX-XXXX)
Current Class Designation (Freshman, Sophomore, Junion, Senior)
Three Separate Grades (Floating Point – Range 0.0 - 100.0)
You should use a class to represent the student record object. Your class should include the following:
A Default Constructor (all values intialized to zeros or nulls)
A Constructor for a student's entire data
A Destructor (must display a notice when an object is destroyed)
A method to add/change a student's data
A method to determine a student's final grade (Average of the three separate grades)
A method to print a student's data, including the final grade (represented as a double)
|
|
|
|
|
This is definitely a homework assignment. We are here to help you go to the next stage, but not provide complete solutions.
You'll find countless examples on Google about this (creating class, public accessors and modifiers, constructors, destructors, variable declaration & initialization, etc). Try it out on your own first and then ask for help if you get stuck.
And post specific questions and not the assignment text posted by your instructor.
- Malhar
|
|
|
|
|
Any help would be gratefully received. You should see from my email address that I'm not trying to get "homework" done for them, in fact this program will be used in QA of clinical treatments so it's vey useful!
I was a programmer for 3-4 years for Infogrames (games), mainly working on export tools for 3D Studio Max, working with the Max SDK and Win32/MFC dialog apps for artists. I learnt programming on the job, and never really had any background knowledge, so I wasn't going to win any awards for my code, and I certainly didn't have the skills to go beyond the stuff I worked on routinely.
I've been away from coding for a while but now I need to get back into it as part of my job here, after a break of 4 or more years. I'm trying to get some good books and learn *properly* the C++ language from the ground up to get the basics, but this project needed to be done a.s.a.p
I did get the program to work with an MFC dialog (see below) but it's very ugly and I can already see "sort of" how it should be done properly with a class or two, maybe even use STL, but I wanted to ask if anyone could spare the time to suggest a good way to deal with it, even just in design terms (though code snippets would be great also!)
Here is the file format which is exported from a medical instrument.
Measurement Export Matrixscan 1.1
Date: 20/01/2006 11:47:01
Cols:27
Rows:27
Measurement Values:
2.314591E-02;2.654959E-02;2.981629E-02;
I've trimmed the values, in actual fact it can be up to 27 rows of 27 items, separated by semi colon (and not always square array!)
What my program is doing in a very ugly way is using Getline on a file stream to read in each line bit by bit, using colon separators at first to get the header info, then using semi colons on the data after creating a new float array.
At the moment I'm only reading in the central row and column into 2 separate arrays (but I'm going to change that to read the whole array and then be able to process any row or column)
For each of the two arrays thus extracted I have to:
- use the centre point as the 100% value
- work out 50% value, and using interpolation, work out which fractional array index that refers to to get an effective field size, eg, if the 50% value is between array[3] and array[4], I interpolate to get an answer of 3.xx. This occurs in two places, one before and one after the centre point (these are 2D profiles shaped like a top hat but with a dip in the middle of the profile).
- Once I have the field size for each array, I work out 80% of that field size, and then have to work out which elements in the array fall within those values, so if I get a field size of 21.1 cm (each array element in the data is 1 cm apart), that means 10.55 either side of the middle element, so I would include only the 10 elements each side of the centre
* upgraded this bit to do the same but using the whole 2D array
- I then go along each row/column and look at corresponding data points equidistant from the centre. Eg, if array[13] is the middle of a 27 sized array, I compare array12 and array 14, array11 and array15, to work out the biggest ratio between those pairs, and which side of the centre it occurs
- I also work out the highest and lowest value in the whole array within the 80% section of the 50% region (relative to the centre point)
I have this as an MFC Dialog which uses CFileDialog to open a list of files (OFN_MULTISELECT) then a process button to process the selected file, which is all done in one big block top to bottom in a single function, with no real error checking and I'm sure lots of redundancy
I have a feeling a better way to do this would be to have a 2DArray type class, with array data and header details, have functions to load and process this data, perhaps have more generic file import class? and also more generic array processing to allow me to "get" a specific element, row or column from the 2D array which I currently store as a 1D array and use indexes to look up a specific cell
I hope that makes sense, any comments or feedback welcome, and you can email me if you want to discuss further
cheers,
lee
|
|
|
|
|
Sorry wrong forum, moved to Visual C++
|
|
|
|
|
|
First of all, you should check "Ignore HTML tags in this message..." check-box. Some of your code is obscured. Second, this appears to be a C++ question and not a C++/CLI question.
|
|
|
|
|