Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- void cw_1();
- void cw_2();
- void cw_3();
- void cw_4();
- void cw_5();
- void cw_6(int *sum, int *a, int *b);
- int cw_6(int *a, int *b);
- void cw_7(float *area, float r);
- float cw_7(float *r);
- string cw_8(int *a, int *b);
- int cw_9(int *a);
- int cw_10(int *tab, int *size);
- int main()
- {
- cw_1();
- cout<<"..."<<endl;
- cw_2();
- cout<<"..."<<endl;
- cw_3();
- cout<<"..."<<endl;
- cw_4();
- cout<<"..."<<endl;
- cw_5();
- cout<<"..."<<endl;
- int sum = 0, a = 6, b=15;
- cw_6(&sum, &a, &b);
- cout<<sum<<endl;
- cout<<cw_6(&a, &b)<<endl;
- cout<<"..."<<endl;
- float area = 0, r = 8;
- cw_7(&area, r);
- cout<<area<<endl;
- cout<<cw_7(&r)<<endl;
- cout<<"..."<<endl;
- int a_8=45, b_8=44;
- cout<<cw_8(&a_8, &b_8)<<endl;
- cout<<"..."<<endl;
- int a_9 = 6;
- cout<<"Silnia z "<<a_9<<" wynosi : "<<cw_9(&a_9)<<endl;
- cout<<"..."<<endl;
- int tab[] = {8, 6, 2, 6}, size = 4;
- cout<<"Suma wartosci elementow z tablicy wynosi: "<<cw_10(tab, &size)<<endl;
- return 0;
- }
- void cw_1(){
- int a = 15;
- cout<<a<<endl;
- cout<<(intptr_t)&a<<endl;
- }
- void cw_2(){
- int *a, b=20;
- cout<<(intptr_t)&b<<endl;
- cout<<b<<endl;
- a = &b;
- cout<<(intptr_t)&a<<endl;
- cout<<(intptr_t)a<<endl;
- cout<<*a<<endl;
- }
- void cw_3(){
- int a=14, *w_a = &a;
- float b=6.7, *w_b = &b;
- char c='x', *w_c = &c;
- cout<<"a = "<<a<<endl;
- cout<<"b = "<<b<<endl;
- cout<<"c = "<<c<<endl;
- cout<<"Adres a = "<<(intptr_t)&a<<endl;
- cout<<"Adres b = "<<(intptr_t)&b<<endl;
- cout<<"Adres c = "<<(intptr_t)&c<<endl;
- cout<<"Wartosc sadresu a = "<<*w_a<<endl;
- cout<<"Wartosc sadresu b = "<<*w_b<<endl;
- cout<<"Wartosc sadresu c = "<<*w_c<<endl;
- }
- void cw_4(){
- int a=6, b=8;
- int *w_a = &a, *w_b = &b;
- cout<<*w_a + *w_b<<endl;
- }
- void cw_5(){
- int a=6, b=9;
- int *w_a = &a, *w_b = &b;
- cout<<*w_a * *w_b<<endl;
- }
- void cw_6(int *sum, int *a, int *b){
- *sum = *a + *b;
- }
- int cw_6(int *a, int *b){
- return *a + *b;
- }
- void cw_7(float *area, float r){
- *area = M_PI * r * r;
- }
- float cw_7(float *r){
- return M_PI * *r * *r;
- }
- string cw_8(int *a, int *b){
- string result;
- if(*a > *b){
- result = "Liczba " + to_string(*a) + " jest wieksza od " + to_string(*b);
- } else if(*b > *a){
- result = "Liczba " + to_string(*b) + " jest wieksza od " + to_string(*a);
- }else{
- result = "Liczby sa sobie rowne";
- }
- return result;
- }
- int cw_9(int *a){
- if(*a == 0) return 1;
- else{
- //*a -= 1;
- (*a)--;
- return (*a+1) * cw_9(a);
- }
- }
- int cw_10(int *tab, int *size){
- int sum = 0;
- int iterator = 0;
- for(int *i=&iterator; *i<*size; (*i)++){
- sum += *(tab+*i);
- }
- return sum;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement