National Chiao Tung University OOP Recitation Course Liu Yu-Jiun 2009/3/11 National Chiao Tung University
Introduction Recitation Course for Object Oriented Programming (#1538). TA: 劉育君 Email: liuyj.ellen@gmail.com TA time: Tue. 13:30~15:30 8 times: 1 point; all times: 2 points
Outline Useful Tool for C++ The Concept of Pointer Examples Exercises HW1 Announcement
Useful Tools Website: C++ Library Reference http://www.cplusplus.com/reference/ http://www.cppreference.com/wiki/ google Debug step by step in Dev-C++. cout
Pointer A Pointer to int, double, etc. Example: double *p; // p is “point type” variable p may contain a pointer to a variable of type double.
Examples
Exercise 1 Enter two numbers m and n on screen, and create a m*n array. Then set all values in this array be 2, and output them. Input: Output: 3 4 2 2 2 2 2 2 2 2
Exercise 2 Advanced: Input: Output: 3 2 2 2 2 1 2 2 2 3
Exercise 3 2.28 Write a program that inputs a five-digit integer, separates the integer into its individual digits and prints the digits separated from one another by three spaces each. input: 42339 output: 4 2 3 3 9
Exercise 4 2.29 Write a program that calculates the squares and cubes of the integers from 0 to 10 and uses tabs to print the following neatly formatted table of values: output: integer square cube 0 0 0 1 1 1 2 4 8 ... 10 100 1000
HW1 Assignment Input Sample Output Sample 3 1 withdraw 1000 from a0012 deposit 1000 to a0102 transfer 500 from a0102 to a1102 withdraw 300 from a1102 2 deposit 1000 to a0123 transfer 300 from a0123 to a1023 4 1 3 2 1 3 2 5 1 error query! deposit 1000 to a0102 transfer 300 from a0123 to a1023
HW1 Assignment Deadline: 2009/3/24 11:59 p.m. Score: HW1 TA: Passing one test data gets one point, total 10 points. HW1 TA: 吳昭瑩 lachao@gmail.com