|
its nt my homework....actually i need find a solution how the reload card systems are workin its for dat..so far i tried using array...i cant get it..plz help me if u can..bcause i left very little time to do this..
|
|
|
|
|
Reload card system??
It looks like you didn't even attempt to solve the problem. If you urgently require people to do work for you perhaps you should be paying for it. As a hint, look up srand(), rand() and the % modulus operator.
|
|
|
|
|
|
It would not be kind for someone to solve this trivial problem for you. If it's not homework, then you must be getting paid to do it. Which makes your employer a fool, to entrust this work on someone obviously not capable of doing it. But, if I write this code for you, then your boss will ask you to write something else, and you'll still have no idea. You need to either confront your boss about the fact that you're not hired to be a programmer, or you need to admit to him that you lied about being one.
Or, you could start with the advice you've been given, write some code, and post some questions here when you get stuck.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Perhaps the std::random_shuffle algorithm will be of interest to you.
Steve
|
|
|
|
|
I agree that the problem may be simple enough for anyone who is a programmer (or becomming a programmer) to try to solve. You are asking for code, not for clarification on some doubt you have. How would you feel if I asked "can you fill out my tax form for me? please help urgently!"?
Anyway, I will assume you had some problem expressing yourself, and, in fact, you are a newbie and what you don't know how to do is to open a window and draw on it. If that is the case I sugest you start with a simpler language, like Visual Basic. If you must do it in C then I sugest you create an application with the MFC application Wizard and then look for GDI functions in the help. For random numbers you can use rand() and srand(), as already sugested, if the random sequence quality is not an issue in your application.
When you have, at least, tried to do it yourself, and if you have some problem making it work, then come back and make a new post clearly stating what you have done and the problem you are having. I'm sure a lot of people will offer to help if you show you have done, at least, an effort.
Rilhas
|
|
|
|
|
The problem I have with MFC is that I can only display BMP pictures. A teacher told me 1 way is to the the extra features of bmp and put it onto the raw image. This website http://en.literateprograms.org/BMP_decoder_(C) gave information about it, but i dont understand it at all. Is there any other alternative that I can use so that MFC can display RAW. If not can any1 direct me to information that can convert RAW to BMP in C++.
Thankyou
|
|
|
|
|
Tito-K4L wrote: <quote>A teacher told me 1 way is to the the extra features of bmp and put it onto the raw image.
What extra features?
You have posted this question again, but still have not clarified what you mean by "raw image". The website you provided simply describes the binary structure of the BMP format and how to interpret its data.
If you just want to get the binary data you can call GetDIBits on the bitmap.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/bitmaps_7gms.asp[^]
If you want to convert a variety of RAW images from various digital camera manufacturers, you were already provided a link in the thread that you deleted.
http://www.cybercom.net/~dcoffin/dcraw/[^]
|
|
|
|
|
Sorry forgot to fix that line.
its "to add the extra features". I will explain with abit more detail, I am making a program to enhance images, such as sharpening and bluring. I was introduced to RAW image since it provides you all the values within the image. All you have to do is read the image then apply any mathematical algorithms.
RAW image, what i mean by it is that if you have any program, say adobe, there is a format called RAW, which you can save it in. I want a code or so to transform that RAW image into bmp, because MFC can only display bmp.
I will look into that website, sorry for deleteing message but I felt it was too vague the question i asked in yesterday's message.
By the way, I think the correct term is decoding a RAW image into BMP
Thanks
-- modified at 10:36 Sunday 30th April, 2006
|
|
|
|
|
|
A RAW image contains just image data. A bitmap contains all the image data, plus a header. In fact, there's no conversion ever possible that creates more data than you start with. If you're getting images from a camera, they may come down in a > 8 bit format. However, writing filters to use those higher formats is a pain in the bum, and you'd need to look into the format of the camera whose RAW format you want to use. As for conversion, you'd need to look into tone mapping, or you can just re range the values so that 0>whatever scales back to 0>255. If you create a DIBSection, you will have a bitmap and you'll be able to iterate over the pixels and modify them directly.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I think what you need is cximage[^]. It can load all the most common image types and display them.
-Saurabh
|
|
|
|
|
I have a question regarding Binary Trees. I have to read an input file, then traverse the tree, and then print out the results of the traversal. I can understand what has to be done, but when it comes to translating it into C++ language, I get stuck.
It is a genealogy tree, with advisors and advisees assigned to them. I have to construct the tree for a sequence of name pairs, and traverse the tree to output the list of the names and the levels as I visit each node in the tree. The advisor name in the first pair of names in the text file is the given list for the root node name.
A sample input
alonzo.church hartely.rogers
alonzo.church samuel.kleene
alonzo.church manuel.blum
hartley.rogers pat.fischer
samuel.kleene rob.constable
samuel.kleene paul.axt
pat.fischer dennis.ritchie
should produce this output
alonzo.church 1
hartley.rogers 2
samuel.kleene 2
manuel.blum 2
pat.fischer 3
rob.constable 3
paul.axt 3
dennis.ritchie 4
The text file is on my computer: "TestInput.txt".
Any help is welcomed, and appreciated.
Thank you for you information.
D.
-- modified at 10:01 Sunday 30th April, 2006
|
|
|
|
|
Blah Blah Blah 29 wrote: alonzo.church 1
hartley.rogers 2
samuel.kleene 2
manuel.blum 2
pat.fischer 3
rob.constable 3
paul.axt 3
dennis.ritchie 4
Which means:
alonzo.church is the root node.
hartley.rogers , samuel.kleene , and manuel.blum are the 2nd tier.
pat.fischer , rob.constable , and paul.axt are the 3rd tier.
dennis.ritchie is the farest node.
Maxwell Chen
|
|
|
|
|
Ok, now I understand. It's just that I don't know what to do when it comes to reading an input file, and defining a binary tree based on the input file.
|
|
|
|
|
|
Blah Blah Blah 29 wrote: It's just that I don't know what to do when it comes to reading an input file
So start there. Once you can successfully read, parse, and print the contents of said file, then you can move on to manipulating a binary tree. I would suggest not mixing the two together until you have a firm grasp of the fundamentals of each.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|
|
I would use a std::set .
Steve
|
|
|
|
|
He was trying to do some binary tree stuffs. std::set is of red-black tree.
Maxwell Chen
|
|
|
|
|
A red-black tree is a type of binary tree - specifically a type of self balancing binary tree.
Steve
|
|
|
|
|
OK.
Maxwell Chen
|
|
|
|
|
Hi
I am new to C++ and have come across a couple of problem I'm having difficulty to solve.
Problem 1
The code below is a function which adds data to an array and validates the input. I am having difficulty when a user hit the return key by accident, the code cycles through the options but does not allow any more input and goes into a inifite loop. I have tryed using cin.ignor() and different varients with no luck. I have bolded the code which is the problem.
#define VSIZE 3
void UserInput(char arrStudent [VSIZE][30])
{
char chTemp [200] = {' '};
system("cls");
cout<<"\n****** Student Detail Screen ******" <<endl<<endl;
for (int n = 0;n<VSIZE;n++)
{
int nValid = 0;
cout << "Details for student number "<<n<<":"<<endl<<endl;
cout << "Please input Students Name"<<endl;
cout << "(maximum of 30 characters): ";
do
{
cin.ignore();
cin.get(chTemp,200,'\n');
if(strlen(chTemp) =< 0)
{
cout << "Name contains no characters, Please try again: ";
cin.ignore();
cin.get(chTemp,200);
}
if(strlen(chTemp) > 30)
{
cout << "Name contains " << strlen(chTemp) << " characters, Please input a shorter name: ";
cin.ignore();
cin.get(chTemp,200);
}
else
{
nValid = 1;
}
}
while (nValid == 0);
strcpy(arrStudent[n],chTemp);
}
}
Problem two - this will be part of the above code, i think it reletivly simple but i cant seem to get it to work. I wanted it so if they type exit instead of a name it would exit the loop.
#define VSIZE 3
char chTemp [200] = {' '};
for (int n = 0;n<VSIZE;n++)
{
if (chTemp[200] == 'exit')
{
n = VSIZE;
cout <<"TEST";
}
}
Any help would be great. Thanks
Helen
|
|
|
|
|
Problem 1
for (int n = 0; n < VSIZE; n++)
{
int nValid = 0;
cout << "Details for student number "<<n+1<<":"<<endl<<endl;
cout << "Please input Students Name"<<endl;
cout << "(maximum of 30 characters): ";
do
{
cin.getline(chTemp,200);
if(strlen(chTemp) == 0)
{
cout << "Name contains no characters, Please try again: ";
}
else if(strlen(chTemp) > 30)
{
cout << "Name contains " << strlen(chTemp) << " characters, Please input a shorter name: ";
}
else
{
nValid = 1;
}
}
while (nValid == 0);
strcpy(arrStudent[n],chTemp);
}
It's inefficient but I guess you are just starting out so it's fine
Did they state that you are not supposed to use STL? If not std::string is convenient.
Edit:
Another thing to note is that a C string is just an array of characters with a terminating null. If it can't find the 0, then it can go past the buffer allocated and keep going till it hits a 0. This also means that if you need a C string that can store up to 30 characters, you need to have a buffer size of 31 so you can store that terminating null character.
Problem 2
if(chTemp[200] == "exit")
All you happen to be doing here is comparing two pointer values (or their addresses) and not the actual string data. You would need to call (strcmp(chTemp, "exit") == 0) to see if the string data is actually the same.
-- modified at 13:45 Sunday 30th April, 2006
|
|
|
|
|
HI haitch79
In first problem, try to use getline instead of get(...) or simply write the following code to get input
gets(chTemp);
in problem 2, to compare your string with exit, write following line.
gets(chTemp);<br />
if (!strcmp(chTemp, "exit"))
{<br />
do something;<br />
}
i hope this will solve your problem. tell us if problem remains...
Good luck.
We Believe in Excellence
www.aqueelmirza.cjb.net
-- modified at 13:40 Sunday 30th April, 2006
|
|
|
|
|
Hi
Thanks for all your help. after reading your posts, I have rearanged the code so it is a bit more logical and used bool varible for the flaging. I replaced get with getline and it seems to work a treat.
Im not sure what STL is, but i have seen examples like what was writen around, we havnt been taught about it but i dont think that means we cant use it.
Thanks again
Helen
|
|
|
|
|