diff --git a/odd.cpp b/odd.cpp new file mode 100644 index 0000000..8f64106 --- /dev/null +++ b/odd.cpp @@ -0,0 +1,17 @@ +#include +using namespace std; +int findOdd(const vector numbers){ + int x = 0,ans = 0; + for(int i = 0 ; i < numbers.size() ; i++){ + x=0; + for (int j = 0 ;j < numbers.size() ; j++){ + if (numbers[i] == numbers[j]){ + x += 1; + } + } + if (x % 2 != 0){ + ans=numbers[i]; + } + } +return ans; +} diff --git a/sum.cpp b/sum.cpp new file mode 100644 index 0000000..6328857 --- /dev/null +++ b/sum.cpp @@ -0,0 +1,20 @@ +#include +#include +using namespace std; +int digital_root(int n) +{ + int sum = 0 ; + int a = 0; + while (sum < 10) { + sum += n /10; + } + if (sum >= 10){ + while (a < 10){ + a += sum % 10; + } + return a; + } + else{ + return sum; + } +} \ No newline at end of file