 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
appalsap Moderator
Reputation: 0
Joined: 27 Apr 2006 Posts: 6753 Location: Pakistan
|
Posted: Fri Feb 01, 2008 4:49 pm Post subject: |
|
|
| You don't need to add a bunch of cases, when a div by 0 occurs an exception is thrown and you can catch that.
|
|
| Back to top |
|
 |
BEO-WULF Expert Cheater
Reputation: 0
Joined: 27 Jan 2008 Posts: 138 Location: Green Bay, Wisconsin
|
Posted: Sat Feb 02, 2008 2:01 am Post subject: |
|
|
| Losplagos wrote: | | Code: | #include "Rev0"
using std::cout;
using std::cin;
using std::endl;
using losBasicI::inpute;
using losBasicI::input;
using losBasicI::inputmm;
using losBasicMath::losRound;
double add (double x, double y);
double mult(double x,double y);
double deduct(double x,double y);
double divide(double x ,double y);
int main()
{
double x = 0.0, y = 0.0;
int choose = 0;
bool loop = true;
while(loop == true)
{
cout << "0:Quit" << endl << "1:adding" << endl << "2:deducting" << endl << "3:multiplying" << "\n" << "4:dividing"<< endl << "Please make your choice: " ;
choose = inputmm(0,5);
switch(choose)
{
case 0:
cout << "Good bye" << endl;
loop = false;
break;
case 1:
cout<<"Please input the first number to be added: ";
x = losRound<double>(input<double>(),4);
cout << "2nd number please:" ;
y =losRound<double>(input<double>(),4);
cout<< x << "+" << y << "=" << losRound<double>(add ( x, y ),4) << endl;
break;
case 2:
cout << "Please input the first number to be deducted: ";
x = losRound<double>(input<double>(),4);
cout << "2nd number please: " ;
y = losRound<double>(input<double>(),4);
cout << x << "-" << y <<"=" << deduct(x , y) << "\n" ;
break;
case 3:
cout << "Please input the first number to be multiplied: " ;
x = losRound<double>(input<double>(),4);
cout << "2nd number please: " ;
y = losRound<double>(input<double>(),4);
cout << x << " times " << y << "=" << losRound(mult(x, y), 4) << endl;
break;
case 4:
cout << "Please input the first number to be divided: " ;
x = losRound<double>(input<double>(),4);
cout << "2nd number please: " ;
y = losRound<double>(inpute<double>(0),4);
cout << x << "/" << y << "=" << losRound(divide(x,y),4) << endl;
break;
}
}
}
double add (double x,double y )
{
return x + y;
}
double mult (double x,double y)
{
return x*y;
}
double deduct(double x ,double y)
{
return x-y;
}
double divide(double x,double y)
{
return x/y;
}
|
Cleaned up the code a little and here is Rev0 make sure it is in the same directory as the .cpp file.
| Code: |
#include <iostream>
#include <math.h>
namespace losBasicI
{
template <typename T>
T input()
{
T returnvalue;
std::cin >> returnvalue;
while (std::cin.fail())
{
std::cout << "Bad input Try again: ";
std::cin.clear(); // Clear failbit
std::cin.sync(); // Sync the stream
std::cin >> returnvalue; // Try again
}
return returnvalue;
}
template <typename T>
T inputmm(T min, T max) //Always use this before a switch No execeptions
{
T returnvalue;
std::cin >> returnvalue;
while(std::cin.fail()||returnvalue < min||returnvalue > max)
{
std::cout << "Bad input Try again: ";
std::cin.clear(); // Clear failbit
std::cin.sync(); // Sync the stream
std::cin >> returnvalue; // Try again
}
return returnvalue;
}
template <typename T>
T inpute(T equal)
{
T returnvalue;
std::cin >> returnvalue;
while(std::cin.fail()||returnvalue == equal)
{
std::cout << "Bad input Try again: ";
std::cin.clear(); // Clear failbit
std::cin.sync(); // Sync the stream
std::cin >> returnvalue; // Try again
}
return returnvalue;
}
} // End of namespace losbasici
namespace losBasicMath
{
template <typename T>
T losRound(T num, int decimalplaces)
{
switch(decimalplaces)
{
case 1:
num = floor(num*10)/10;
break;
case 2:
num = floor(num*100)/100;
break;
case 3:
num = floor(num*1000)/1000;
break;
case 4:
num = floor(num*10000)/10000;
break;
case 5:
num = floor(num*100000)/100000;
break;
case 6:
num = floor(num*1000000)/1000000;
}
return num;
}
}
|
If you need help with Rev0 feel free to ask it is just for rounding and checking your input. |
--------------------------------------------------------------------------------
its the dll code .exe its been broken up into 3 main sequinces and [Q!=0] is reproduced version of the numerical number that does not equal to the right number thats why it crashed is becuase it cant equal to its self only to the last partal code.
---------------------------------------------------------------------------------
_________________
4 L1F3 ( + [__] : : ) 4 L1F3 |
|
| Back to top |
|
 |
NuclearPowered Master Cheater
Reputation: 0
Joined: 30 Dec 2007 Posts: 345
|
Posted: Tue Feb 05, 2008 3:22 pm Post subject: |
|
|
Lol it exits when you fill in a number like 54 at the menu...
mine is better
(use dev C++ to access the whole project)
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|