Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- byte x[]={7,7,7,2,5,7,7};
- size_t sizex = 7;
- byte output[10];
- void setup() {
- Serial.begin(57600);
- int index=0;
- for(int i =0;i<sizex;)
- {
- int temp=0;
- if(x[i]==7){ //check if 7
- do{ //sum 7 into temp
- temp+=7;
- i++;
- }while(x[i]==7); // check if the next one is still 7
- output[index]=temp; //push to array
- index++;
- }else {
- output[index]=x[i]; //ใสเลย ไม่ใช่ 7
- index++;
- i++;
- }
- }
- for(int i =0;i<10;i++)
- Serial.println(output[i]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement