W
Wolftein
Invitado
[C++] Modulo Matematica [Ao]
Misma Funct Q La De Ao pero En c++
Misma Funct Q La De Ao pero En c++

C++:
#include <cstdlib>
#include <stdio.h>
#include <time.h>
double sqr(int x) {
return x*x;
}
int AddVar(int var,int addon,int max)
{
var += addon;
if (var > max)
{
return max;
}
return var;
}
long Porcentaje(long Total,long Porc)
{
return (Total * Porc) / 100;
}
int SD(int N)
{
int digit;
int suma;
do {
digit = (N % 10);
suma += digit;
N /= 10;
}
while (N > 0);
return suma;
}
int SDM(int N)
{
int digit;
int suma;
do
{
digit = (N % 10);
digit -= 1;
suma += digit;
N /= 10;
}
while (N > 0);
return suma;
}
int Complex(int N)
{
if(N % 2 != 0){
return N * SD(N);
}
else
{
return N * SDM(N);
}
}
int Distancia(WorldPos wp1,WorldPos wp2)
{
return abs(wp1.X - wp2.X) + abs(wp1.Y - wp2.Y) + (abs(wp1.Map - wp2.Map) * 100);
}
double Distance(long X1,long Y1,long X2,long Y2)
{
return sqr(((Y1 - Y2) ^ 2 + (X1 - X2) ^ 2));
}
int RandomNumber(int LowerBound, int UpperBound)
{
srand ( time(NULL) );
return (rand()%UpperBound+LowerBound);
}