Last active
August 29, 2015 14:19
-
-
Save RezaBidar/acf9216ce8fceac38604 to your computer and use it in GitHub Desktop.
ali moosaei c++ problems
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include<cmath> | |
using namespace std ; | |
double degreeToRadian(double d){ | |
// 1 degree = 0.01745329252 radian ; | |
return d * 0.01745329252 ; | |
} | |
long moadele1(int x, int a, int b){ | |
// y = ax + b ; | |
return a * x + b ; | |
} | |
double power(double a , int x){ | |
// a^x | |
return pow(a , x) ; | |
} | |
float price(float x , float s){ | |
// x gheymate avalie | |
// s darsade sood | |
return (x + (x * (s / 100) ) ) ; | |
} | |
void greater(int a , int b){ | |
if(a > b){ | |
cout << "big = " << a << endl ; | |
cout << "small = " << b << endl ; | |
}else if(b > a){ | |
cout << "big = " << b << endl ; | |
cout << "small = " << a << endl ; | |
}else{ | |
cout << "both of them are equal : " << a << endl ; | |
} | |
} | |
void rightRectangle(int a , int b , int c){ | |
if(a*a + b*b == c*c || b*b + c*c == a*a || a*a + c*c == b*b) | |
cout << "Yes" << endl ; | |
else | |
cout << "No" << endl ; | |
} | |
void moadele2(int a , int b , int c){ | |
//ax^2 + bx + c = 0 | |
float delta = b*b - (4 * a * c) ; | |
if(delta > 0){ | |
cout << "x1 = " << (float)(-1 * b + sqrt(delta)) / (float)(2 * a) << endl; | |
cout << "x2 = " << (float)(-1 * b - sqrt(delta)) / (float)(2 * a) << endl; | |
}else if(delta == 0){ | |
cout << "x = " << (float)(-1 * b + sqrt(delta)) / (float)(2 * a) << endl; | |
}else { | |
cout << "we have no answer" << endl ; | |
} | |
} | |
int main(){ | |
//test it | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment