Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // bulenda_funkcje_19.11.2017.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <iostream>
- using namespace std;
- int Razydwa(int z)
- {
- return z*2;
- }
- char Znaki(char a, char b, int x)
- {
- if(x>0)
- return a;
- else
- return b;
- }
- double Licz(double x, double y)
- {
- return (x<250 || y<250 ? y : x*x-y*y);
- }
- int Rekurencja(int n)
- {
- if(n<0)
- return 0;
- return 3*n+Rekurencja(n-1);
- }
- int _tmain(int argc, _TCHAR* argv[])
- {
- //zadanie 1
- /*
- int liczba=0;
- cout<<"Podaj liczbe: ";
- cin>>liczba;
- cout<<"Twoja liczba: "<<liczba<<", *2 = "<<razydwa(liczba)<<endl;
- */
- //zadanie2
- /*
- char znak1, znak2;
- int liczba2=0;
- cout<<"Podaj znak1: ";
- cin>>znak1;
- cout<<"Podaj znak2: ";
- cin>>znak2;
- do
- {
- cout<<"Podaj liczbe: ";
- cin>>liczba2;
- }while(liczba2==0);
- cout<<"\nZnak: "<<znak1<<" jest dla liczb dodatkich."<<endl;
- cout<<"Znak: "<<znak2<<" jest dla liczb ujemnych."<<endl;
- if(Znaki(znak1, znak2, liczba2)==znak1)
- cout<<"\nTwoja liczba: "<<liczba2<<" jest dodatnia. ("<<znak1<<")"<<endl;
- else
- cout<<"\nTwoja liczba: "<<liczba2<<" jest ujemna. ("<<znak2<<")"<<endl<<endl;
- cout<<"Trojargumentowy operator."<<endl;
- cout<<(Znaki(znak1, znak2, liczba2)==znak1 ? "Twoja liczb jest dodatnia" : "Twoja liczba jest ujemna")<<endl;
- */
- //zadanie 3
- /*
- double x=0, y=0;
- cout<<"Podaj pierwsza liczbe: ";
- cin>>x;
- cout<<"Podaj druga liczbe: ";
- cin>>y;
- //podpunkt a
- cout<<"Wynik podpunktu a: "<<Licz(x ,y)<<endl;
- //podpunkt b
- y=300;
- cout<<"Wynik podpunktu b(wynik dzielony przez 5.5) y=300: "<<Licz(x ,y)/5.5<<endl;
- */
- //podpunkt c
- int liczba3=0;
- do
- {
- cout<<"Podaj liczbe: ";
- cin>>liczba3;
- }while(liczba3==0 || liczba3<0);
- cout<<"Wynik podpunktu c: "<<Rekurencja(liczba3)<<endl;
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement