Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- #include <cstdlib>
- #include <ctime>
- using namespace std;
- int kostka(int n){
- srand(time(NULL));
- if(n<=0){
- return -1;
- }
- else {
- return (rand()%(n)+1);
- };
- }
- double objetosc(int r){
- if(r<=0){
- return -1;
- }
- else {
- return ((4/3.)*M_PI*pow(r,3));
- }
- }
- int silnia(int liczba){
- int x=1;
- for(int i=1;i<=liczba;i++){
- x *=i;
- };
- return x;
- }
- double sin(int x, int N){
- int n=0;
- double sin=0;
- for(int i=n;i<=N;i++){
- sin+= (pow(-1,i)*(pow(x,2*i+1)/silnia(2*i+1)));
- };
- return sin;
- }
- int main()
- {
- cout<<kostka(6)<<endl;
- cout<<objetosc(5)<<endl;
- cout<<sin(1,5);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement