Ad
#include <algorithm>

template< class T >
void Swap( T& a, T& b ) { std::swap( a, b ); }
Code
Diff
  • #define Or(A,B)  (A|B)
    #define Xor(A,B) (A^B)
    #define And(A,B) (A&B)
    • bool Or ( bool a, bool b ){ return a | b; }
    • bool Xor ( bool a, bool b ){ return a ^ b; }
    • bool And ( bool a, bool b ){ return a & b; }
    • #define Or(A,B) (A|B)
    • #define Xor(A,B) (A^B)
    • #define And(A,B) (A&B)
Code
Diff
  • #include <numeric>
    
    int stray(std::vector<int> numbers)
    {    
        int sum = std::accumulate( numbers.begin(), numbers.end(), 0);
        int sample = numbers[0] == numbers[1] ? numbers[1] : numbers[2];
        return sum % sample + ( numbers.size() == (sum / sample) ? sample : 0 );
    }
    • int stray(std::vector<int> numbers) {
    • for(auto n = numbers.begin(); n != numbers.end(); ++n ){
    • if (*n != numbers[0]) {
    • if (*n != *(n + 1))
    • return *n;
    • else
    • return numbers[0];
    • }
    • }
    • };
    • #include <numeric>
    • int stray(std::vector<int> numbers)
    • {
    • int sum = std::accumulate( numbers.begin(), numbers.end(), 0);
    • int sample = numbers[0] == numbers[1] ? numbers[1] : numbers[2];
    • return sum % sample + ( numbers.size() == (sum / sample) ? sample : 0 );
    • }
Code
Diff
  • bool Or  ( bool a, bool b ){ return a | b; }
    bool Xor ( bool a, bool b ){ return a ^ b; }
    bool And ( bool a, bool b ){ return a & b; }
    
    • bool Or(bool a, bool b){
    • return a ? true : (b ? true : false);
    • }
    • bool Xor(bool a, bool b){
    • return a ? (b ? false : true) : (b ? true : false);
    • }
    • bool And(bool a, bool b){
    • return a ? (b ? true : false) : false;
    • }
    • bool Or ( bool a, bool b ){ return a | b; }
    • bool Xor ( bool a, bool b ){ return a ^ b; }
    • bool And ( bool a, bool b ){ return a & b; }
Code
Diff
  • #define makeupper toupper
    • char makeupper(char letter)
    • {
    • return toupper(letter);
    • }
    • #define makeupper toupper