วันศุกร์ที่ 19 กรกฎาคม พ.ศ. 2556

Function (Medium)

Preposition
Write a function that take an integer n and prints a list of squares and cubes of the number 1-n. From main(), read the number n  from the user.

Code
int n=9;
int i=1;
void draw() {
  Print();
}
void Print() {
  if (i<=n) {
    print(i);
    i++;
  }
}


Output
123456789


Text book name : Programming and Problem solving with Java second edition
Author : Nell Dale and Chip Weems
ISBN : 978-0-7637-3402-2

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

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