cmath գրադարանը

cmath գրադարանը տալիս է տարբեր մաթեմատիկական ֆունկցիաներ օգտագործելու հնարավորթյուն։

Մի քանի օրինակ cmath գրադարանով՝

#include <iostream>
#include <cmath>
using namespace std;

int main() {
		cout << abs(-10) << endl;  // absolute value of -10 => 10
		cout << abs(0) << endl;    // absolute value of 0 => 0
		cout << sin(0) << endl;    // sin(0) in radians
		cout << pow(2, 8) << endl; // 2^8 => 256
		cout << sqrt(9) << endl;   // square root of 9 => 3
		return 0;
}

endl-ը (endline) տպելուց՝ նոր տող անցնելու համար է։ Օրինակում endl-ի միջոցով բոլոր արդյունքները տպվելու են առանձին տողերի վրա։

Վարժություն՝

Մուտքում տրված է x (double) փոփոխականի արժեքը։

Ելքում տպել abs(x), round(x), floor(x) և ceil(x)։

Մուտք

Ելք

10.793561228915799

10.793561228915799 11.0 10.0 11.0

Constraints

Time limit: 0.2 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue