|
void PrintCom(char *letterSet,int setLen)
{
int NoOfCom=0;
for(int i=0;i<setLen;i++)
{
for(int j=i+1;j<setLen;j++)
{
cout<<letterSet[i]<<letterSet[j];
NoOfCom++;
}
cout<<endl;
}
cout<<NoOfCom<<endl;
}
the letterSet is a pointer of the set array,setLen is the length of the array.
|
|
|
|
|
Hi, i use srand ( ) in order to fill in an array with values but i want to esure that each value will appear only one time.
Is there something i can do with the function to avoid comparing array elements to check it?
Thanks
chrizpl
|
|
|
|
|
Someone might have a clever way of doing that but here is my suggestion that avoids checking the "random" array. Create a KeyValue type collection that contains the number range values as keys (0, 1, 2, 3, etc.) and a value initially false. Before adding a random number in the "random" array, search the KeyValue collection with the random number. If the value is false, add it to the "random" array and then set the value to true.
-- modified at 7:13 Saturday 18th February, 2006
|
|
|
|
|
Can you be more clear please? What i want to do is to fill up a 2-d[3][3] array with numbers from 0-8. I want each number to be appear in my array but only one time. Each time i run my program i want the sequence of the numbers to change.
example of how i want to look like my array is: 3 5 7
2 1 0
4 6 8
chrizpl
|
|
|
|
|
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
|
|
|
|