daily pastebin goal
53%
SHARE
TWEET

Untitled

a guest Feb 22nd, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. int method(vector<int> a, int size, int min = 100500, int i=0 ){
  7.    
  8.     if(a[i] < min) min = a[i];
  9.     if(i == size-1) return min;
  10.    
  11.     return method(a,size,min,i+1);
  12.    
  13. }
  14. int method2(int a, int summ = 0){
  15.    
  16.     if(a % 10 == 0) return summ;
  17.    
  18.     return method2(a/10, summ+(a%10));
  19.    
  20. }
  21.  
  22.  
  23. bool method3(string str,int right, int left= 0 ) {
  24.    
  25.  
  26.     if(str[left] != str[right-1]) return false;
  27.     if(right-1 == 0 || left == str.size()-1) return true;
  28.    
  29.     return method3(str, right-1,  left+1);
  30. }
  31. int method4(int a, int summ = 0){
  32.    
  33.     if(a % 10 == 0) {
  34.         return (summ == 0) ? 1 : summ;
  35.     }
  36.    
  37.     return method4(a/10, summ+1);
  38.    
  39. }
  40. int main() {
  41.     string str;
  42.     cin>> str;
  43.    
  44.     cout<< method3(str ,str.size())<< endl;
  45.    
  46. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top