Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ZADANIE 1
- #include <iostream>
- using namespace std;
- float suma(float a, float b);
- int main(){
- cout << "suma to: " << suma(10.5, 19.2) << endl;
- cout << "suma to: " << suma(10.2, 16.2) << endl;
- cout << "suma to: " << suma(10.7, 11.2) << endl;
- cout << "suma to: " << suma(10.9, 12.2) << endl;
- }
- float suma(float a, float b){
- return a+b;
- }
- ZADANIE 2
- #include <iostream>
- #include <math.h>
- using namespace std;
- int WARTOSC_BEZWZGLEDNA(int a);
- int main(){
- cout << "wartosc bezwzgledna to: " << WARTOSC_BEZWZGLEDNA(10) << endl;
- cout << "wartosc bezwzgledna to: " << WARTOSC_BEZWZGLEDNA(16) << endl;
- cout << "wartosc bezwzgledna to: " << WARTOSC_BEZWZGLEDNA(-16) << endl;
- cout << "wartosc bezwzgledna to: " << WARTOSC_BEZWZGLEDNA(-20) << endl;
- }
- int WARTOSC_BEZWZGLEDNA(int a){
- return abs(a);
- }
- ZADANIE 3
- #include <iostream>
- #include <math.h>
- using namespace std;
- bool CZY_PARZYSTA(int a);
- int main(){
- cout << CZY_PARZYSTA(4) << endl;
- cout << CZY_PARZYSTA(5) << endl;
- cout << CZY_PARZYSTA(7) << endl;
- cout << CZY_PARZYSTA(190) << endl;
- }
- bool CZY_PARZYSTA(int a){
- if (a % 2 == 0) return true;
- else return false;
- }
- ZADANIE 4
- #include <iostream>
- #include <math.h>
- using namespace std;
- void SZLACZEK(int a, char b);
- int main(){
- SZLACZEK(10, 'f');
- cout << endl;
- SZLACZEK(5, 's');
- cout << endl;
- SZLACZEK(15, '*');
- cout << endl;
- SZLACZEK(29, '-');
- }
- void SZLACZEK(int a, char b){
- for (int i; i < a; i++){
- cout << b;
- }
- }
- ZADANIE 5
- #include <iostream>
- #include <math.h>
- using namespace std;
- int POTEGA(int x, int y);
- int main(){
- cout << POTEGA(2, 6) << endl;
- cout << POTEGA(2, 2) << endl;
- cout << POTEGA(4, 3) << endl;
- cout << POTEGA(4, 5) << endl;
- }
- int POTEGA(int x, int y){
- int z = x;
- for (int i = 1; i < y; i++) z *= x;
- return z;
- }
- ZADANIE 6
- #include <iostream>
- #include <math.h>
- using namespace std;
- float OBWOD_TROJKATA(float x, float y, float z);
- int main(){
- float x, y, z;
- cout << "wprowadz boki trojkata: " << endl;
- cin >> x >> y >> z;
- if (OBWOD_TROJKATA(x, y, z) == -1) cout << "nie da sie stworzyc trojkata!" << endl;
- else cout << "obwod trojkata to: " << OBWOD_TROJKATA(x, y, z) << endl;
- }
- float OBWOD_TROJKATA(float x, float y, float z){
- if (x<y+z && y<x+z && z<x+y) return x+y+z;
- else return -1;
- }
- ZADANIE 7
- #include <iostream>
- #include <math.h>
- using namespace std;
- int SILNIA(int a);
- int main(){
- cout << SILNIA(0) << endl;
- cout << SILNIA(1) << endl;
- cout << SILNIA(2) << endl;
- cout << SILNIA(3) << endl;
- cout << SILNIA(4) << endl;
- cout << SILNIA(5) << endl;
- cout << SILNIA(6) << endl;
- cout << SILNIA(7) << endl;
- cout << SILNIA(8) << endl;
- }
- int SILNIA(int a){
- int b = 1;
- for (int i = 2; i <= a; i++) b *= i;
- return b;
- }
- ZADANIE 8
- #include <iostream>
- #include <math.h>
- using namespace std;
- int MAX(int a, int b, int c);
- int main(){
- cout << MAX(1,2,3) << endl;
- cout << MAX(4,2,3) << endl;
- cout << MAX(1,2,3) << endl;
- cout << MAX(1,190,6) << endl;
- }
- int MAX(int a, int b, int c){
- return max(a, max(b,c));
- }
- ZADANIE 9
- #include <iostream>
- #include <math.h>
- using namespace std;
- int DZIELNIKI(int n);
- int main(){
- DZIELNIKI(4);
- DZIELNIKI(40);
- DZIELNIKI(51);
- DZIELNIKI(412);
- }
- int DZIELNIKI(int n){
- for (int i = 1; i <= n; i++) if (n%i == 0) cout << i << endl;
- }
- ZADANIE 10
- #include <iostream>
- #include <math.h>
- using namespace std;
- float ILORAZ(float a, float b);
- int main(){
- cout << "wprowadz 2 liczby" << endl;
- int a, b;
- cin >> a >> b;
- if (ILORAZ(a,b) == -1) cout << "Nie dziel przez 0" << endl;
- else if (ILORAZ(a, b) == -2) cout << "Nie wprowadzaj liczb ujemnych" << endl;
- else cout << "wynik to: " << ILORAZ(a,b) << endl;
- }
- float ILORAZ(float a, float b){
- if (b == 0) return -1;
- else if (a < 0 || b < 0) return -2;
- else return a/b;
- }
- ZADANIE 11
- #include <iostream>
- #include <math.h>
- using namespace std;
- int PODZIELNOSC(int a, int b);
- int main(){
- int a, b;
- cout << "wprowadz 2 liczby: "<<endl;
- cin >> a >> b;
- cout << endl;
- cout << "Twoje liczby to: ";
- PODZIELNOSC(a,b);
- }
- int PODZIELNOSC(int a, int b){
- for (int i = pow(10, a-1); i < pow(10, a); i++) if (i%b == 0) cout << i << " ";
- }
- ZADANIE 12
- #include <iostream>
- #include <math.h>
- using namespace std;
- int LICZBA_CYFR(int a);
- int main(){
- cout << LICZBA_CYFR(10)<<endl;
- cout << LICZBA_CYFR(101)<<endl;
- cout << LICZBA_CYFR(10123241)<<endl;
- cout << LICZBA_CYFR(0)<<endl;
- cout << LICZBA_CYFR(1)<<endl;
- }
- int LICZBA_CYFR(int a){
- if (a == 0) return 1;
- int i = 0;
- while (a >= pow(10, i)) i++;
- return i;
- }
- ZADANIE 13
- #include <iostream>
- #include <math.h>
- #include <string>
- using namespace std;
- int SUMA_CYFR(int a);
- int main(){
- cout << "wprowadz liczbe: " << endl;
- int a;
- cin >> a;
- int wynik = SUMA_CYFR(a);
- while (wynik >= 10) wynik = SUMA_CYFR(wynik);
- cout << "wynik to: " << wynik << endl;
- }
- int SUMA_CYFR(int a){
- string b = to_string(a);
- int c = 0;
- for (int i = 0; i < b.length(); i++) c += b[i] - '0';
- return c;
- }
- ZADANIE 14 I 15
- #include <iostream>
- #include <math.h>
- #include <string>
- using namespace std;
- float POLE_TROJKATA(float a, float b);
- float POLE_TROJKATA(float x1, float y1, float x2, float y2, float x3, float y3);
- int main(){
- cout << POLE_TROJKATA(1, 3) << endl;
- cout << POLE_TROJKATA(2, 6) << endl;
- cout << POLE_TROJKATA(1,1,5,2,2,5) << endl;
- cout << POLE_TROJKATA(0,0,3,0,0,3) << endl;
- }
- float POLE_TROJKATA(float a, float b){
- return a*b/2;
- }
- float POLE_TROJKATA(float x1, float y1, float x2, float y2, float x3, float y3){
- float a = sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
- float b = sqrt(pow(x2 - x3, 2) + pow(y2 - y3, 2));
- float c = sqrt(pow(x3 - x1, 2) + pow(y3 - y1, 2));
- float o = (a+b+c)/2;
- return sqrt(o*(o-a)*(o-b)*(o-c));
- }
Advertisement
Add Comment
Please, Sign In to add comment