Advertisement
rajeshinternshala

Untitled

Mar 5th, 2024
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.95 KB | None | 0 0
  1. #include<iostream>
  2. #include<vector>
  3. using namespace std;
  4.  
  5. string plusMult(vector <int> A)
  6. {
  7.   unsigned int Reven = 0, Rodd =0;
  8.   unsigned int tempEven =1;
  9.   unsigned int tempOdd = 0;
  10.   for(int i=0; i < A.size(); i++)
  11.   {
  12.     if(i %2 == 0){
  13.     if(i != tempEven)
  14.     {
  15.       if( i+2 < A.size())
  16.       {
  17.         Reven += (A[i] * A[i+2]);
  18.         tempEven = i+2;
  19.       }
  20.       else
  21.       {
  22.         Reven += A[i];
  23.       }
  24.     }
  25.     }
  26.   if(i %2 != 0){
  27.     if(i != tempOdd)
  28.     {
  29.       if( i+2 < A.size())
  30.       {
  31.         Rodd += (A[i] * A[i+2]);
  32.         tempOdd = i+2;
  33.       }
  34.       else
  35.       {
  36.         Rodd += A[i];
  37.       }
  38.     }
  39.   }
  40.   }
  41.   cout << "\n" <<Reven << "\n" << Rodd << "\n";
  42.   Reven = Reven % 2;
  43.   Rodd = Rodd % 2;
  44.   string result = " ";
  45.   if(Rodd > Reven)
  46.   {
  47.     result = "ODD";
  48.   }
  49.   if(Reven > Rodd)
  50.   {
  51.     result = "EVEN";
  52.   }
  53.   if(Reven == Rodd)
  54.   {
  55.     result = "NEUTRAL";
  56.   }
  57.   return result;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement