Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 107,144 C++ Programmers for FREE! Ask your question and get quick answers from experts. There are 1,336 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



One Source Code,different Results

 
Reply to this topicStart new topic

> One Source Code,different Results, MACROS v/s FUNCTIONS v/s COMPILERS

Rating  3
born2c0de
Group Icon



post 13 Jan, 2005 - 09:57 AM
Post #1


This one's basically shows that MACROS when used in different compilers can give different results. This one teaches you to analyse C++ code and read it in Assembly and draw Conclusions about the results.
Really interesting if you read it completely...
It's Attached as an HTML File.


Attached File(s)
Attached File  macfun.htm ( 23.14k ) Number of downloads: 1362
Go to the top of the page
+Quote Post


Register to Make This Ad Go Away!

smartC
*



post 27 Jul, 2007 - 05:29 AM
Post #2

int main()
{
int num, i= 0, ii;
int currentDivide[7] = {1000, 500, 100, 50, 10, 5, 1};
int count[7];
char characters[7] = "'M', 'D', 'C', 'L', 'X', 'V', 'I'";
while((scanf("%c", characters)) != '\n'){
for(i = 0; i < 7; i++){
count[i] = num / currentDivide[i];
num %= currentDivide[i];

}
for(i = 0; i < 7; i++)
if(count[i] != 4 || i == 0)
for(ii = 0; ii < count[i]; ii++)
cout<<currentDivide[i];
else
cout<<currentDivide[i]<< currentDivide[i-1];
}



return 0;
}



Please, I want this codes to print the Numeric equivalent of the Roman Figures. I have a bit changed it to the switch/ case but special cases like VI/IV, XI/IX, LC/CL will not come up separetely. The are 6, 11, and 150 respectively. See the basic case condition


switch(cha){

case 'M':
sum += 1000;
cout<<sum;
:::
:::
:::
case 'I':
sum += 1;
cout<<sum;
}

This thus gives VI/IV as 6 instead of 6/4. Same as IX/XI giving 11 instead of 9/11. Can you help for the special cases like IV/VI, XI/IX, LX/XL MX/XM etc?
My email address is smart_ikhu@hotmail.comī
Thanks.




Go to the top of the page
+Quote Post


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 8/27/08 07:31PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month