From 4a6331088a0de479c1f27ba398ac3281418cd5bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1ndly=20Gerg=C5=91?= Date: Fri, 1 May 2020 17:58:05 +0300 Subject: [PATCH] chore: Lab07 --- lab07/01.cpp | 22 ++++++++++++++++++++++ lab07/02.cpp | 22 ++++++++++++++++++++++ lab07/03.cpp | 25 +++++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 lab07/01.cpp create mode 100644 lab07/02.cpp create mode 100644 lab07/03.cpp diff --git a/lab07/01.cpp b/lab07/01.cpp new file mode 100644 index 0000000..d4656ff --- /dev/null +++ b/lab07/01.cpp @@ -0,0 +1,22 @@ +#include +using namespace std; + +int fib(int n){ + if(n <= 1){ + return n; + } + return fib(n-1) + fib(n-2); +} + +int main(){ + int n; + cout<<"N = "; + cin>>n; + + for(int i=0; i +using namespace std; + +int convert(int number, int base){ + if(number == 0 || base == 10){ + return number; + } + + return (number%base) + 10 * convert(number / base, base); +} + +int main(){ + int n, base; + cout<<"Number: "; + cin>>n; + cout<<"Target base: "; + cin>>base; + + cout<<"Result: "< +#include +using namespace std; + +bool isPalindrome(string str){ + if(!str.size()){ + return true; + } + + if(str.front() != str.back()){ + return false; + } + + return isPalindrome(str.substr(1, str.size() - 2)); +} + +int main(){ + string str; + cout<<"Enter a word: "; + cin>>str; + + cout<<"The word is "<<(isPalindrome(str) ? "" : "not ")<<"palindrome."<