C++ Programming

Time & Place
Thursday 08:10-11:00, (TC-208 [94334492])
TAs: cs101-ta-2019
Students enrolled in this class
Deitel C++ How to Program
Ivor Horton's Beginning Visual C++ 2013

Programming Environment

Tips for PuTTY

  1. Why doesn't the keypad work as expected? It keeps sending an escape sequence.
    Ans: These confusing things happen when PuTTY is in "application keypad mode".  Please follow the following steps:
    1. Bring up PuTTY Configuration.
    2. In the left pane, select Terminal - Features.
    3. Put a check mark next to "Disable application keypad mode".
  2. In the "ee" editor, If you want to move a line to somewhere else:
    1. Press Ctrl-K to cut the line
    2. Use cursor key to move to where you want to insert the line
    3. Press Ctrl-L
  3. In the "nano" editor, if you want to move a line to somewhere else:
    1. Press Ctrl-K to cut the line
    2. Use cursor key to move to where you want to insert the line
    3. Press Ctrl-C to paste the line

Tips for Visual C++

  1. Build - Build Solution (Ctrl+Shift+B)
  2. Debug - Start Without Debugging (Ctrl+F5)
  3. Project - Properties
  4. Tools - Options - Text Editor - C++
  5. Help source choices can be changed in the Options dialog box under /Help/Online.
  6. Comments a block of code: Ctrl+K Ctrl+C.
  7. Uncomments a block of code: Ctrl+K Ctrl+U.
  8. Reformat a block of code: Ctrl+K Ctrl+F
  9. Project Properties (Alt-F7) - C/C++ - Preprocessor - Preprocessor Definition
  10. error C4996: 'strtok': This function or variable may be unsafe. Consider using strtok_s instead.
  11. If you cannot find the "Resource View":
  12. View the assembly code generated by Visual C++


  1. C++ FAQ Lite
  2. Stack Overflow is a question and answer site for professional and enthusiast programmers.
  3. My C++ program can be compiled, but clang++ shows lots of warning: warning: conversion from string literal to 'char *' is deprecated [-Wdeprecated-writable-strings]
    You may compile with the option
    "clang++ -Wno-deprecated-writable-strings a.cpp".
  4. How could I connect to the STU.ipv6.club.tw server if I am not inside the campus?
  5. Q: Why can't I type Chinese characters in my editor?
    A: If you are using the "ee" editor, its support for Chinese is incomplete at this moment (until somebody fixs it up). Please try to use "nano" or "vim".
  6. Q: Why can't I create a new project in Visual Studio 2013 in the computer classroom (H-103)?
    A: The administrator did not configure Visual Studio 2013 well, so you will fail to create a new project because of the directory access permission.
    Solution: When you create a new project, change the "Location" to "C:\Users\xxx\Documents\Visual Studio 2013\Projects\". This is the correct path for you to create projects.
    Create Project

Code Writing

  1. Draw a flowchart or write a pseudo code to illustrate the basic idea
  2. Prepare a test case so that after your code is complete, you may verify its correctness.
  3. Keyin your code and check it is correct or not.
  4. If the outcome differs from what you expect, ask yourself why.
  5. For rules about indentation, see GNU Coding Standards.  You may try tools like SourceFormatX Code Formatter.

How will your programming assignments be evaluated



Hands-On Exercise
Extended Reading
Week 1 9/12
Chapter 2: Data, Variables, and Calculations

  1. In which year were you born?
  2. [CFP01] 雞兔同籠
  3. 美珍阿姨
  4. [CFP03] What day is January 1st?
  5. How to submit your homework?
  1. Cornell Note-Taking video
  2. Python Is Now the Most Popular Introductory Teaching Language at Top ­U.S. ­Universities
  3. MIT's Food Computer: The Future of Urban Agriculture?

  4. Google Science Fair
  5. Try, Try Again
  6. BASIC Turns 50, and I Still Miss It
Week 2 9/19
bit, byte
oct, dec,hex
IEEE 754
Data types: int, float, unsigned
Math Library (Reference, PPT)
Quiz 2

  1. sizeof
  2. Bitwise Shift Operator
  3. [CFP02] BMI (body mass index)
  4. [CPP01] Volume and surface area of a sphere
  5. Area of a triangle
  6. [CPP02] Solving Linear Equations

  1. Bit and Byte (6:25) video
  2. Why Do Computers Use 1s and 0s? Binary Explained.video (6:59) video
  3. Binary Numbers and Base Systems as Fast as Possible (lynda.com) (5:19) video
  4. Number Systems Introduction - Decimal, Binary, Octal, Hexadecimal & BCD Conversions (30:04)video
  5. Twos complement: Negative numbers in binary (13:48)
  6. What most schools don't teach video (Code.org video)
  7. Let's teach kids to code video
  8. Checking the Graphics Card Specifications on Your Computer
Week 3 9/26 Chapter 3: Decisions and Loops

Quiz 3
  1. [CPP03] Fibonacci sequence
  2. [CPP04] Sum of integers
  3. [CPP05] Prime Number Test
  4. [CPP06] Prime Numbers <= N

  5. [Moodle] Prime Numbers with sqrt()
  6. Plot cos(x) with characters
  7. Multiply Exercise * 10
  8. [Moodle] Move Around
  9. [CFP06] 9x9 Multiplication Table
  10. [CFP08] Beginning day of a month
  11. [CFP09] Calendar of a month
  12. Print the calendar of a year
  13. Ten Additions
  14. [Moodle] Additions with Limited Time
  15. Parabola
  16. [Moodle] Parabola (2)
  17. Rotated sin(x)

How We Teach Introductory Computer Science Is Wrong
Best Time-Management Apps for Students

Microsoft Skips Windows 9, Reveals Windows 10
Week 4 10/3
break, continue

Quiz 4
  1. Syracuse sequence
  2. [EX22] Drunken Man Walking
  3. Drunken Man Walking (2)

Goto statemetn considered harmful

UK teenager jailed for not disclosing password
The Real Threat to Economic Growth Is the Digital Divide
How to develop seamlessly in the cloud
[TED] Amy Cuddy: Your body language may shape who you are
Week 5 10/10 National Birthday

  1. 15 Windows Utilities You Can't Live Without
  2. Multitasking
  3. [BBC] Academic Listening Part 2 - Lectures: Introduction
Week 6 10/17
Midterm Exam (1)

Week 7
Chapter 4: Arrays and Strings
2-D Arrays

  1. [CFP11] Dice2
  2. [CFP12] Determinant
  3. Magic Square
  4. [EX14] Prime Numbers with an Array
  5. [CFP13] Merging Two Arrays
  6. [CFP14] Transposition Cipher
  7. [CPP08] Dice Rolling
  8. [CPP09] Matrix Multiplication
  9. [CPP10] Caesar Cipher
  10. ID Number Verifier

The next 5,000 days of the webvideo
How to Build a Website
How to Download and Watch Free Movies Online Legally
Week 8
10/31 Chapter 4: Pointers
String Manipulation (str functions)
Using UTF-8 as the internal representation for strings in C and C++ with Visual Studio

Why Gmail Services Aren't Free
Simon Sinek: How great leaders inspire actionvideo
  • People don't buy what you do; they buy why you do it.
  • Law of Diffusion

Week 9
11/7  Chapter 5: Introducing Structure into Your Programs
recursive functions

Sherry Turkle: Connected, but alone?video
Google doesn't care where you went to college
Hacker Lexicon: What Are White Hat, Gray Hat, and Black Hat Hackers?
RFC 1855 - Netiquette Guidelines
Week 10 11/14 Chapter 6: More about Program Strucutre
pass by value, pointer, reference
default value
function overloading

Quiz 8
Quiz 9
John Underkoffler points to the future of UIvideo
TED blends animation with education at new website
First Look: Inside the Army’s App Store for War
MIT Creates Amazing UI From Levitating Orbs
ZeroN - Levitated Interaction Element video
Week 11 11/21

Function Pointers and Callback Functions

Quiz 10
The Sound of Rainingvideo
世界上最辛苦的工作 - World's Toughest Jobvideo

10 Tips to Become a Better Presentervideo
The Mobile Phone in Developing Nations

Week 12
11/28 Midterm 2
Quiz 11
Analyst's View: PDF - Pretty Dangerous Format?
The Story behind LINE App Development
Asian Mobile App LINE Opens its API
57 Chat APIs: Skype, MSN Messenger and Google Talk
Week 13 12/5 Separate your code in several files
linker, macro processor
build your own library
Ncurse Library (Tutorial, PPT)
Quiz 12
  1. Refactor 1A2B
  2. Running Q
  3. [Moodle] Moving Q
  4. [Moodle] Horse Racing
  5. [Moodle] Horse Racing (2)
Debugging with gdb
SSD vs HDD: What's the Difference?
MIT's Oxygen Project
Week 14 12/12 File I/O: text
Chapter 6: Exception Handling (P.229)
Quiz 13
  1. File Processing (Word Count)
  2. Subtitle of a Movie
Week 15
12/19 Chapter 7: Defining Your Own Data Type
 struct, qsort, asctime
Time Library (Reference)

  1. [CPP15] HW: sort rational numbers (q/p)
  2. struct tm
  3. [CFP22] Astrological Sign (2)
  4. [Moodle] Shuttle Bus
  5. Linked List
  6. Sort Rational Numbers
  7. Show Name (1)
  8. [CFP25] Show Name (2)
  9. [CFP26] Sort Name (1)
  10. [CFP27] Sort Name (2)
Students Should be Co-Laborers, Not Customers
Week 16 12/26 Binary File I/O
Quiz 14
  1. Load a binary file (e.g. .WAV) into memory
  2. The Sound of MusicPDF
Tech world preps to honor 'Father of Computer Science' Alan Turing, as centenary nears
第六感驚人的潛 力 Pranav Mistryvideo
Week 17 1/2 Linked-List, Trees,
Chapter 4: Dynamic Memory Allocation, Demo

Computer Science for Fun
Tesla, a Software Defined Car
NTT DoCoMo Vision (1)
NTT DoCoMo Vision (2) [wmv]
NTT DOCOMO Mobile Futurevideo
Week 18
1/9 Final Exam



  1. SoloLearn: Learn to Code for Free!
  2. Simple DirectMedia Layer (SDL)
  3. Tiled Map Editor
  4. Object-Oriented Graphics Rendering Engine (OGRE); OgreAL for audio.
  5. CodeFights
  6. ACM UVa Online Judge
  7. 線上解題系統 (NKNUSH)
  8. Advanced Programming (NSYSU)
  9. CPE 一星題
  10. Google Code University
  11. Codecademy
  12. Code for America
  13. Flowchart Drawing:
  14. Dia
  15. Dia for Windows
  16. An Introduction to Programming in Go
  17. Build Web Application with Golang


  1. Newton's Method
  2. What day is January 1?
    Ref: UVA 12019
  3. Calendar
  4. 190 - Circle Through Three Points
  5. Christmas Tree
  6. Prime Number
  7. Greatest Common Divisor
  8. Sorting
  9. Card Shuffling
  10. Dec2Float: 40 decimal = 0x42200000 IEEE Single Precision
  11. 蓊鬱錦簇科技二館 - 有蓊鬱的樹木圍繞著科技二館,使建築物融入大自然的美景中,更具生命力。
  12. 光鮮亮麗的山中城堡 - 雲群波濤洶湧、山脈層巒疊嶂及蓊鬱樹木圍繞,暨南大學校園無疑是美麗的歐式莊園。
  13. TypingTest (雙手聯彈)
  14. 小學乘法
  15. Sokoban
  16. Tetris
  17. [SourceForge] Mega Mario


  1. Pigeons with tiny backpacks test the air in London, and share tweeting
  2. Intel Labs Creating Robots of the Future
  3. 10 Ways Not to Be a Jerk Online
  4. 15 Windows Utilities You Can't Live Without
  5. [DVD] Hidden Figures
  6. IBM at 100: From typewriters to the cloud
  7. Future of the car (智慧汽車, 51 min) 447.18 F996