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."<