Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * nazwa projektu:
- * wersja projektu:
- * opis:
- */
- #include <iostream>
- #include <windows.h>
- #include <cmath>
- using namespace std;
- /*********** SEKCJA DEKLARACYJNA ***********/
- //ZADANIE 1
- void wypisz_dane() {
- string imie = ""; // tu uzupelnic
- string nazwisko = ""; // tu uzupelnic
- cout<<"Imie: "<<imie<<endl;
- cout<<"Nazwisko: "<<nazwisko<<endl<<endl;
- }
- //ZADANIE 2
- int silnia(int x) {
- if(x==0)
- return 1;
- else if(x>=1)
- return x*silnia(x-1);
- }
- float newton(int n, int k) {
- return silnia(n)/(silnia(k)*silnia(n-k));
- }
- //ZADANIE 3
- float iloczyn(int n) {
- float suma=0.0;
- for(int k=1; k<=n; k++) {
- float element = (k*k*k)/(2*k+1);
- suma+=element;
- }
- return suma;
- }
- //ZADANIE 4
- float poleKuli(float r) {
- return 4*M_PI*r*r;
- }
- //ZADANIE 5
- float suma(float a, float b) {
- return a+b;
- }
- /*************** SEKCJA MAIN ***************/
- int main() {
- system("chcp 1250>NUL");
- //ZADANIE 1
- wypisz_dane();
- //ZADANIE 2
- int a = 5;
- cout<<"Silnia liczby "<<a<<" wynosi "<<silnia(a)<<endl<<endl;
- int n=7;
- int k=2;
- cout<<"Wartosc symbolu newtona dla n="<<n<<", k="<<k<<" wynosi "<<newton(n,k)<<endl<<endl;
- //ZADANIE 3
- int N;
- cout<<"Podaj N:";
- cin>>N;
- cout<<"Wartosc iloczynu dla N="<<N<<" wynosi "<<iloczyn(N)<<endl<<endl;
- //ZADANIE 4
- cout<<"Podaj promien kuli (z dokladnoscia do milimetra po kropce):";
- float promien;
- cin>>promien;
- cout<<"Pole kuli o promieniu = "<<promien<<" wynosi "<<poleKuli(promien)<<endl<<endl;
- //ZADANIE 5
- float s1, s2;
- for(int i=1; i<=5; i++) {
- cout<<"Podaj 1. liczbe:";
- cin>>s1;
- cout<<"Podaj 2. liczbe:";
- cin>>s2;
- cout<<"Suma liczb "<<s1<<" i "<<s2<<" wynosi "<<suma(s1,s2)<<endl;
- }
- system("pause");
- return 0;
- }
- /************ SEKCJA DEFINICYJNA ***********/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement