วันอาทิตย์ที่ 9 พฤศจิกายน พ.ศ. 2557

print only the first character of each word from a character

void setup () {
  char [] sentense = {
    'l', 'e', 'a', 'r', 'n', 'i', 'n', 'g', ' ', 'p', 'r', 'o', 'g', 'r', 'a', 'm'
  };
  TheFirstChar(sentense);
}
void TheFirstChar(char [] a) {
  char space = ' ';
  if (a[0] != space) {
    println (a[0]);
  }
  for (int i = 0; i<a.length-1; i++) {
    if (a[i] == space) {
      println (a[i+1]);
    }
  }
}

ไม่มีความคิดเห็น:

แสดงความคิดเห็น