วันอาทิตย์ที่ 13 กันยายน พ.ศ. 2558

Lab4-Sum of integers

void setup(){
  size(300,300);
  background(#CCCC00);
  int x = 100;
  int y = 100;
  int firstNum = 0;
  int lastNum = 10;
  int sum = 0 ;
  textSize(30);
  text("Sum of "+firstNum,x-50,y);
  text("to "+lastNum,x+90,y);
  text("is",x+50,y+40);
  while(firstNum<=lastNum){
    sum+=firstNum;
    firstNum++;
  }
 text(+sum,x+35,y+80);
}

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

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