Advertisement
wvathh

codeMic

Nov 30th, 2015
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. byte x[]={7,7,7,2,5,7,7};
  2. size_t sizex = 7;
  3. byte output[10];
  4. void setup() {
  5.   Serial.begin(57600);
  6.  
  7.  
  8.   int index=0;
  9.   for(int i =0;i<sizex;)
  10.   {
  11.     int temp=0;
  12.     if(x[i]==7){ //check if 7
  13.       do{              //sum 7 into temp
  14.         temp+=7;
  15.         i++;
  16.       }while(x[i]==7);  // check if the next one is still 7
  17.      
  18.     output[index]=temp; //push to array
  19.     index++;
  20.    
  21.     }else {
  22.       output[index]=x[i];    //ใสเลย ไม่ใช่ 7
  23.       index++;
  24.       i++;
  25.     }
  26.   }
  27.  
  28.  
  29.  
  30. for(int i =0;i<10;i++)
  31.   Serial.println(output[i]);
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement