| View previous topic :: View next topic |
| Author |
Message |
samuri25404 Grandmaster Cheater
Reputation: 7
Joined: 04 May 2007 Posts: 955 Location: Why do you care?
|
Posted: Sat Jul 05, 2008 4:30 pm Post subject: |
|
|
| manc wrote: | Thanks everyone for the suggestions, I'm loving them. Here is exactly what Ive learned so far from the course at www.cplusplus.com:
So yeah, you can base any suggestions off that. |
o_O
Why is type casting advanced?
Anyways, maybe you should start looking into some APIs (after you learn type casting... >_> )
_________________
|
|
| Back to top |
|
 |
Heartless I post too much
Reputation: 0
Joined: 03 Dec 2006 Posts: 2436
|
Posted: Sat Jul 05, 2008 7:23 pm Post subject: |
|
|
Make a basic calculator that can add, mulitply, divide, and subtract. That is always lesson 2.
_________________
What dosen't kill you, usually does the second time. |
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8588 Location: 127.0.0.1
|
Posted: Sat Jul 05, 2008 10:04 pm Post subject: |
|
|
Keep going on what they have on that site. It is a good idea to have a general understanding of the things you haven't learned yet.
Templates are used a lot and can be quiet handy in some projects.
Namespaces are common as well.
Exception programming is for error handling and such which you should get to know how to use as well since you will have times where it will be nice to handle errors that will commonly happen under certain circumstances in a given project.
Typecasting is another useful subject for hooking and hacking. As well as creating your own libs and such. You can create your own variable types using typecasting which allows you to do a lot of things with ease.
_________________
- Retired. |
|
| Back to top |
|
 |
nwongfeiying Grandmaster Cheater
Reputation: 2
Joined: 25 Jun 2007 Posts: 695
|
Posted: Sat Jul 05, 2008 10:46 pm Post subject: |
|
|
| Symbol wrote: | Convert numbers (0~999) to actual words, if the input is 534 the output would be Five hundred thirty four.
Try doing it in the shortest way you can.  |
LOL! That would be a good idea.
|
|
| Back to top |
|
 |
Jani Grandmaster Cheater
Reputation: 2
Joined: 29 Dec 2006 Posts: 804
|
Posted: Sun Jul 06, 2008 7:13 am Post subject: |
|
|
| Symbol wrote: | | Convert numbers (0~999) to actual words, if the input is 534 the output would be Five hundred thirty four. | 0 ~ sizeof(int) ;) Also make it convert them to ordinal numbers too.
|
|
| Back to top |
|
 |
WafflesFTW Expert Cheater
Reputation: 0
Joined: 21 Mar 2008 Posts: 131
|
Posted: Sun Jul 06, 2008 8:56 am Post subject: |
|
|
| Try creating classes for complex data structures such as binary node trees, and store values, say your schedule, within those data structures, and then practice retrieving htem and outputting them to a table.
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Sun Jul 06, 2008 12:14 pm Post subject: |
|
|
| Jani wrote: | | Symbol wrote: | | Convert numbers (0~999) to actual words, if the input is 534 the output would be Five hundred thirty four. | 0 ~ sizeof(int) Also make it convert them to ordinal numbers too. |
sizeof(int) = 4.
Ofcourse I assume you mean 0xFFFFFFFF. (4 bilion+ )
First he should try 0~999, he should also concider the input might contain ten~ninteen, so he should fix it so it won't say "Five hundred Ten Three" for 513.
Well since he isn't even trying, I tried doing it myself in the shortest and best way I could.
Here's what I did:
| Code: | #include <iostream>
using namespace std;
char* Array1[] = { "", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine" };
char* Array2[] = { "", "", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety" };
char* Array3[] = { "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen" };
void main(int argc, char* argv[])
{
int num;
char Text[255] = "";
do
{
do { cin >> num; } while (num > 999 || num < 0);
if (num > 0)
{
if (num / 10 % 10 != 1)
sprintf_s(Text, 255, "%s%s%s %s", Array1[num / 100], (num / 100 != 0 ? " hundred " : ""), Array2[num / 10 % 10], Array1[num % 10]);
else sprintf_s(Text, 255, "%s%s%s", Array1[num / 100], (num / 100 != 0 ? " hundred " : ""), Array3[(num % 10)]);
cout << Text << endl;
}
} while (num > 0);
cout << "Zero" << endl;
cin.get();
cin.ignore();
} |
|
|
| Back to top |
|
 |
Jani Grandmaster Cheater
Reputation: 2
Joined: 29 Dec 2006 Posts: 804
|
Posted: Sun Jul 06, 2008 12:56 pm Post subject: |
|
|
| Symbol wrote: | | sizeof(int) = 4. | Not always.
Btw.. Your code is more of C than C++, since std::cout and std::cin are the only C++ stuff(objects) you're using. Why to code in C++, if you don't use it's features?
|
|
| Back to top |
|
 |
Hieroglyphics I post too much
Reputation: 0
Joined: 06 Dec 2007 Posts: 2007 Location: Your bedroom
|
Posted: Sun Jul 06, 2008 1:20 pm Post subject: |
|
|
Make this please. Open source please =]
_________________
|
|
| Back to top |
|
 |
Travis13 Expert Cheater
Reputation: 0
Joined: 17 Feb 2007 Posts: 199
|
Posted: Wed Jul 09, 2008 3:26 am Post subject: |
|
|
| Symbol wrote: | Convert numbers (0~999) to actual words, if the input is 534 the output would be Five hundred thirty four.
Try doing it in the shortest way you can.  |
holy fuck how the hell would u actually make that? i wouldnt even know where to start lol, but also, theres no point to it
_________________
Learning C++, trying, failing, never gonna give up tho  |
|
| Back to top |
|
 |
Zand Master Cheater
Reputation: 0
Joined: 21 Jul 2006 Posts: 424
|
Posted: Wed Jul 09, 2008 3:52 am Post subject: |
|
|
| AFAIK sizeof(int) is 4.
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8588 Location: 127.0.0.1
|
|
| Back to top |
|
 |
Jani Grandmaster Cheater
Reputation: 2
Joined: 29 Dec 2006 Posts: 804
|
Posted: Wed Jul 09, 2008 7:09 am Post subject: |
|
|
| Zand wrote: | | AFAIK sizeof(int) is 4. | C doesn't specify that. It only says something like short int <= int <= long int. And that int must be at least 16-bits long -> sizeof(int) would be 2 there. And what about 16-bit machines?
Getting a bit off topic.. :)
|
|
| Back to top |
|
 |
Zand Master Cheater
Reputation: 0
Joined: 21 Jul 2006 Posts: 424
|
Posted: Wed Jul 09, 2008 7:38 am Post subject: |
|
|
integer = 4 bytes
i mean literally doing like printf("%i", sizeof(int));
|
|
| Back to top |
|
 |
Jani Grandmaster Cheater
Reputation: 2
Joined: 29 Dec 2006 Posts: 804
|
Posted: Wed Jul 09, 2008 7:51 am Post subject: |
|
|
| Zand wrote: | | printf("%i", sizeof(int)); | 2 on my MS-DOS machine. Might be 8 on 64-bit OS, depends on compiler, etc.
|
|
| Back to top |
|
 |
|