C++ Programming



210099a程式設計
Time & Place
Thursday 08:10-11:00, (H-103 [94334493])
TAs: cs102-ta
Students enrolled in this class
82
Deitel C++ How to Program
Ivor Horton's Beginning Visual C++ 2013
http://Course.ipv6.club.tw/C_Programming/CS102/

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. Q: I accidentally messed up the layout of my Visual Studio. What should I do?
    A: Window - Reset Window Layout
  2. Tools - Options - Text Editor - C++
  3. Help source choices can be changed in the Options dialog box under /Help/Online.
  4. Comments a block of code: Ctrl-K Ctrl-C.
  5. Uncomments a block of code: Ctrl-K Ctrl-U.
  6. Reformat a block of code: Ctrl-K Ctrl-F
  7. Project Properties (Alt-F7) - C/C++ - Preprocessor - Preprocessor Definition
  8. error C4996: 'strtok': This function or variable may be unsafe. Consider using strtok_s instead.
  9. If you cannot find the "Resource View":
  10. View the assembly code generated by Visual C++

FAQ

  1. On lilina, why g++ complains that it does not recognize "stoi()"?
    A: Use "g++ -std=c++11".
  2. I have the following code. How do I tell the program there is no more input?
    #include <iostream>
    using std::cin;
    using std::cout;
    
    int main() {
        int sum = 0;
        int i;
        while (cin >> i) {
            sum += i;
        }
        cout << sum << '\n';
        return 0;
    }

    Ans: In Windows, press Ctrl-Z Enter at the beginning of a line. In Unix, press Ctrl-D at the beginning of a line.
  3. Q: In Visual C++, how to change the theme from "Dark" to "Light"?
    A: Tools - Options - Environment - General
  4. Q: In Visual C++, I have "#include <cmath>", but why it still cannot find the constant M_PI?
    A: M_PI is not C standard. If you want to use M_PI, add in your pch.h file.
    Check the article "Precompiled Header Files for further information.
  5. 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".
  6. On my personal computer, I got an error message "LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt".
    Solution: Install Microsoft Visual Studio 2010 Service Pack 1.
  7. DreamSpark FAQ
  8. How could I connect to the STU.ipv6.club.tw server if I am not inside the campus?
  9. 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".
  10. 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
  11. Q: My solution consists of two projects, but I want to use Visual Studio to debug only one of them.
    A: In the Solution Explorer, right-click the project, and choose "Debug - Start New Instance".
  12. Q: During the debugging process, I cannot see the value of variables.
    A: From the menu bar, choose Debug - Windows - Autos.
  13. I created a project to share DLL, but when I release the program I want to use a static library, can I simply change an option instead of re-creating a new project?
    1. Project - Properties - Configuration Properties - General - Use of MFC
      • Change "Use MFC in a Shared DLL" to "Use MFC in a Static Library".
    2. C/C++ options - tab "Code Generation" - Runtime Library
      • Change "Multithreaded DLL (/MD)" to "Multithreaded (/MT)".
  14. Stack Overflow is a question and answer site for professional and enthusiast programmers.
  15. C++ FAQ Lite

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

課程評量方式

Syllabus

  1. 2/17 Arrays and Pointers
    1. Compiler and Linker
    2. pass-by-value, pass-by-pointer, pass-by-reference
    3. a[i] = *(a+i)
    4. malloc
    5. Little Endian
    6. IEEE 754
    7. File I/O, file access (8gua) https://zh.wikipedia.org/zh-tw/%E6%98%93%E7%B6%93%E5%85%AD%E5%8D%81%E5%9B%9B%E5%8D%A6%E7%AC%A6%E8%99%9F_(Unicode%E5%8D%80%E6%AE%B5) Exercise/64gua.txt
    8. [Article] Why is "using namespace std;" considered bad practice?
    9. [Article] What is the difference between <cstdio> and <stdio.h>?
  2. 2/24 Structure
  3. 3/3 Macro, Debugger, and Ncurses
    1. macro processor
    2. gdb
    3. Build Your Own Library
    4. Ncurses
      • Show current time
    5. Typing Test
    6. TypingClub
    7. Bingo
  4. 3/10 Object, Class
  5. 3/17 Operator Overloading; friend function
    1. cin >> rational
  6. 3/24 STL
  7. 3/31 Inheritance, Virtual Function, & Exception Handling
  8. 4/7 Midterm Exam
  9. 4/14 MFC Drawing
  10. 4/21 Keyboard & Menu
  11. 4/28 Mouse & Drawing
  12. 5/5 Controls
  13. 5/12 Multi-thread Programming
  14. 5/19 Sound File and Audio Output
  15. 5/26 Final
  16. Boost Library and Regular Expressions


Thursday
Quiz
Hands-On Exercise
Extended Reading
More Exercises
Week 1 2/22
Chapter 2: Data, Variables, and Calculations
Quiz 1
  1. Create Mail Filters
  2. Writing C Programs on a FreeBSD server.
  3. In which year were you born?
  4. [CPP01] Volume and surface area of a sphere
  5. [CPP02] Solving Linear Equations
  6. How to submit your homework?
Bash Guide for Beginners
Top 5 Best Linux Text Editors
MIT's Food Computer: The Future of Urban Agriculture?
New report details the prices within the cybercrime market
Top Time Management Apps for Students in 2015
Who are the hackers?
How Hacking, `Phishing' Works video
Google Science Fair
Try, Try Again

[YouTube] Feynman Technique
[YouTube] 5 Steps to Handle a Coding Interview - LeetCode Interview Platform
Offenbach: 霍夫曼的故事 - 船歌 (Barcarolle)video
  1. [CFP01] 雞兔同籠
  2. [CFP02] BMI (body mass index)
  3. [CFP03] What day is January 1st?
Week 2 3/1
Chapter 3: Decisions and Loops
Quiz 2

  1. [CPP03] Fibonacci sequence
  2. [CPP04] Sum of integers
  3. [CPP05] Prime Number Test
  4. [CPP06] Prime Numbers <= N
  5. [CPP07] Print the calendar of January
  6. Draw IO: Free Online Drawing
  7. Gliffy: Online Flowchart Software
  8. Easy flow chart creation with Dia
  9. How to Create a Flow Chart in Microsoft Word
  10. [YouTube] Drawing Flowcharts with Google Drawings
Goto statement considered harmful
What most schools don't teach video (Code.org video)
Let's teach kids to code video
Checking the Graphics Card Specifications on Your Computer

  1. [CFP04] Syracuse sequence (3n+1)
  2. [CFP05] Truth Table
  3. [CFP06] 9x9 Multiplication Table
  4. [CFP07] P → Q
  5. [CFP08] Beginning day of a month
  6. [CFP09] Calendar of a month
  7. Print the calendar of a year

Week 3 3/8
Math Library (Reference, PPT)
Time Library (Reference)
Ncurse Library (Tutorial, PPT)
Quiz 3
  1. [Moodle] Prime Numbers with sqrt()
  2. Plot cos(x) with characters
  3. Multiply Exercise * 10
  4. [Moodle] Move Around
Steamed: Valve Software Battles Video-game Cheaters
Bitcoin Solves a Huge Problem for the Global Economy
Microsoft Skips Windows 9, Reveals Windows 10
Week 4 3/15
Chapter 4: Arrays and Strings
String Manipulation
Quiz 4
  1. [CPP08] Dice Rolling
  2. [CPP09] Matrix Multiplication
  3. [CPP10] Caesar Cipher
  4. [CPP11] Delete Spaces in a String
  5. [CPP12] White Spaces
  6. Running Q
  7. Sokoban (1) - Level Format
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 3/22
Chapter 4: Pointers

Quiz 5
  1. [CPP13] Exchange Sort
  2. [CPP14] Exchange Sort (2)
  3. Ex4_09 - *(primes + i) == primes[i]
  4. [EX14] Prime Numbers with an Array


  1. 15 Windows Utilities You Can't Live Without
  2. Multitasking
  3. [BBC] Academic Listening Part 2 - Lectures: Introduction


Week 6 3/29 Midterm Exam (1)
Seats




Week 7
4/5 溫書假


Microsoft's 'Spartan' browser will replace IE
The next 5,000 days of the webvideo
How to Build a Website
How to Download and Watch Free Movies Online Legally

Week 8
4/12  Chapter 5: Introducing Structure into Your Programs Quiz 6
Five reasons why Windows 8 has failed
Why Windows 8 Has Been Slow to Capture Consumer Mindshare
KickStarter
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
4/19 Chapter 6: More about Program Strucutre
Function Pointers and Callback Functions
Quiz 7 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
Neuromarketing
Week 10 4/26
Quiz 8
Quiz 9
  1. EX7_01.cpp
  2. Addition of Rational Numbers (1)
  3. Addition of Rational Numbers (2)
  4. [CPP15] HW: sort rational numbers (q/p)
  5. struct tm
  6. [CPP16] storeListReversely
  7. [CPP17] storeList
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
  1. Addition of Rational Numbers (3)
  2. [CFP22] Astrological Sign (2)
  3. [Moodle] Shuttle Bus
  4. [CFP23] insertToList
  5. [CFP24] Insert to Binary Tree
Week 11 5/3
Chapter 6: Exception Handling (P.229)
FreeBSD Socket Programming
Beej's Guide to Network Programming
Programming Windows TCP Sockets in C++ for the Beginner
Chapter 7: Classes and Constructors
Quiz 10
  1. Matrix (1)
  2. Matrix (2)
  3. Matrix (3)
  4. Determinant (2)
  5. HW: Horse Racing (3)
The Sound of Rainingvideo
世界上最辛苦的工作 - World's Toughest Jobvideo
How to measure Windows 7 memory usage
10 Tips to Become a Better Presentervideo
The Mobile Phone in Developing Nations
BASIC Turns 50, and I Still Miss It

  1. Reduction of Rational Numbers
  2. Copy Constructor
  3. Wireshark
  4. Show Name (1)
  5. [CFP25] Show Name (2)
Week 12 5/10
Chapter 8: Destructor, Operator Overloading

Quiz 11
  1. EX: Matrix (4)
  2. EX: Matrix (5)
  3. Linked List
  4. Sort Rational Numbers
  5. Horse Racing (4)
  6. TETRIS (7)
  7. TETRIS (8)
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
  1. [CFP26] Sort Name (1)
  2. [CFP27] Sort Name (2)
  3. EX: Matrix (6)
  4. EX: Matrix (7)
  5. EX: Matrix (8)
  6. EX: Matrix (9)
  7. [CFP28] Matrix (10)
Week 13 5/17
Quiz 12
  1. [CPP18] Rational (7)
  2. [HW05] Determinant (3)
    [EX34] Input File Stream
  3. Inverse
  4. TETRIS (9)
  5. TETRIS(10)
  6. utx.log
  7. Load a binary file (e.g. .WAV) into memory
  8. The Sound of MusicPDF
  9. WAVE_FORMAT_PCM
Debugging with gdb, gdb Tutorial
SSD vs HDD: What's the Difference?
MIT's Oxygen Project
  1. [CFP29] Matrix Addition with Rational Entries
  2. [CFP30] Friend Function
  3. [CFP31] Matrix Determinant with Rational Entries
  4. [EX36] File Processing (Word Count)
  5. Subtitle of a Movie
Week 14 5/24
Chapter 10: The Standard Template Library

Quiz 13
  1. A Vector of Strings
  2. [EX38] Vector (1)
  3. [EX39] Vector (2)
  4. TETRIS (11)
  5. TETRIS (12)
  6. TETRIS (13)
  7. TETRIS (14)
  1. [CFP32] Sorting A Vector of Rational Numbers in Ascending Order
  2. [CFP33] Sorting a Vector of Rational Numbers in Descending Order
  3. Matrix
Week 15
5/31 Midterm Exam (2)


Students Should be Co-Laborers, Not Customers
Week 16 6/7
Chapter 12: Windows Programming with the Microsoft Foundation Classes
Chapter 14: Drawing in a Window
Quiz 14
  1. [EX] Lines and Rectangles
  2. [EX] Circles
  3. [HW] Pentagon
  4. [HW] Brush
  5. [HW] National Flags
Tech world preps to honor 'Father of Computer Science' Alan Turing, as centenary nears
第六感驚人的潛 力 Pranav Mistryvideo
  1. [Moodle] Star
  2. [Moodle] Square Wave
  3. [Moodle] Sine Wave
  4. Circle intersection
  5. Chapter 15: Working with Menus and Toolbars
    Display BITMAP filesPowerPoint
  6. How to display bitmap file
  7. Displaying Bitmaps in Visual C++ using Resources
  8. Code Guru - Displaying a Bitmap from a BMP File
  9. MSDN Bitmap Class
  10. [Moodle] TextOut()
  11. CreateFont()
  12. [Moodle] Polar Coordinate
Week 17 6/14
Chapter 16: Working with Dialogs and Controls
  • Edit Box
  • List Box
  • Enable a Button; Using Radio Buttons
Tutorial to MFC Controls

Computer Science for Fun
Tesla, a Software Defined Car
NTT DoCoMo Vision (1)
NTT DoCoMo Vision (2) [wmv]
NTT DOCOMO Mobile Futurevideo

Week 18
6/21 Final Exam


Hands-On

  1. lint, gprof, gcov
  2. cscope
  3. GNU cflow
  4. MFC CSocket
  5. Endpoint C++ Socket Library
  6. codePost - AutoGrader and Code Commenting
  7. LeetCode - prepare you for technical interviews
  8. HackerRank
  9. AlgoExpert.io
  10. SoloLearn: Learn to Code for Free!
  11. Simple DirectMedia Layer (SDL)
  12. Tiled Map Editor
  13. Object-Oriented Graphics Rendering Engine (OGRE); OgreAL for audio.
  14. CodeFights
  15. CodeWars
  16. ACM UVa Online Judge
  17. 線上解題系統 (NKNUSH)
  18. Advanced Programming (NSYSU)
  19. CPE 一星題
  20. Geeks for Geeks
  21. Google Code University
  22. Codecademy
  23. Code for America
  24. Flowchart Drawing:
  25. Dia
  26. Dia for Windows
  27. An Introduction to Programming in Go
  28. Build Web Application with Golang
  29. BOOST C++ Libraries
  30. Antti Laaksonen, Competitive Programmer’s Handbook

Exercise

  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. Card Shuffling
  9. Dec2Float: 40 decimal = 0x42200000 IEEE Single Precision
  10. 蓊鬱錦簇科技二館 - 有蓊鬱的樹木圍繞著科技二館,使建築物融入大自然的美景中,更具生命力。
  11. 光鮮亮麗的山中城堡 - 雲群波濤洶湧、山脈層巒疊嶂及蓊鬱樹木圍繞,暨南大學校園無疑是美麗的歐式莊園。
  12. Bubble Sort
  13. TypingTest (雙手聯彈)
  14. 小學乘法
  15. Mine Sweeping
  16. Sokoban
  17. Block Puzzle
  18. Tetris
  19. binary tree
  20. Fractal
  21. Celebrating 50 years of Kids Coding - LOGO
  22. LOGO Tutorial
  23. LOGO Interpreter: Map + Function Pointers
  24. [SourceForge] Mega Mario

Reading

  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. IBM at 100: From typewriters to the cloud
  6. Future of the car (智慧汽車, 51 min) 447.18 F996
  7. [edX] Introduction to C++
  8. [OCW] Introduction to C++
  9. [Reddit] C++ Questions
  10. [StackOverflow] C++ Questions
  11. MFC FAQ
  12. Tech Interview Pro
  13. GeeksforGeeks