軟體實驗: C-Lab7 虞台文. Lab7 Issues Lab 7-1  On-Off bits counting Lab 7-2  ACSII File Verification.

Slides:



Advertisements
Similar presentations
Functional Programming Lecture 15 - Case Study: Huffman Codes.
Advertisements

What is he doing?.
1/8 AND, OR and NOT b How many boys? b How many girls? b How many blue? b How many red?
Starting Out with C++, 3 rd Edition 1 Chapter 10 – Characters, Strings, and the string Class.
CREATING a HUFFMAN CODE EVERY EGG IS GREEN E ///// V/V/ R // Y/Y/ I/I/ S/S/ N/N/ Sp /// V/V/ Y/Y/ I/I/ S/S/ N/N/ R // Sp /// G /// E /////
Technology ICT Option: Data Representation. Data Representation In our everyday lives, we communicate with each other using analogue data. This data takes.
1 DATA ABSTRACTION: USER DEFINED TYPES AND THE CLASS.
C Program Design Supplements 主講人:虞台文. Content Who takes the return value of main() ?
P449. p450 Figure 15-1 p451 Figure 15-2 p453 Figure 15-2a p453.
Review session – working on case studies Instructor – Gokcen Cilingir Cpt S 121 (June 29, 2011) Washington State University.
Basic C Programming Data Types and Arithmetic Operations 01/30/15.
1 12/08/03SW Abingdon and Witney College Binary Converting to and from decimal.
Huffman code uses a different number of bits used to encode characters: it uses fewer bits to represent common characters and more bits to represent rare.
Java Bits CS Data versus Information Bits are just bits (no inherent meaning) -conventions define relationship between bits and numbers -given a.
CSCI 1100/1202 January 16, Why do we need variables? To store intermediate results in a long computation. To store a value that is used more than.
Aloha Aloha What you see: What the computer sees: binary number columns binary number columns
軟體實作與計算實驗 1 Lecture 9 Classification Two mappings from position to color Linear combination of distances to centers RBF: Linear combination of exponential.
MA/CSSE 473 Day 31 Student questions Data Compression Minimal Spanning Tree Intro.
1 Homework Turn in HW2 tonight HW3 is on-line already Questions?
Practical Electronics & Programming
1 CS 192 Lecture 5 Winter 2003 December 10-11, 2003 Dr. Shafay Shamail.
Lecture Objectives  To learn how to use a Huffman tree to encode characters using fewer bytes than ASCII or Unicode, resulting in smaller files and reduced.
INPUT/OUTPUT STATEMENT ADDITION SLIDES. Console.ReadLine() – Use to get the input (String) from user Convert string to other data type – int.Parse() 
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 5 – Dental Payment Application: Introducing.
Bringing Data into SAS From Menu: –File –Import Data –Spreadsheet example first Pick file by browsing Select Library and Member (we will talk about this.
軟體實驗: C-Lab5 虞台文. Lab5 Problem Write a program which accepts a text file as input and outputs how many characters, lines, and words the file contains.
Required Functions for Program 3 int readUntilValidBaseRead( ); int readNumbersReturningValue( int base ); int decimalValueOf( char chDigit ); bool isValid(
CSE1222: Lecture 3The Ohio State University1. Assignment Operations  The C++ assignment operator is: =  Examples: x = 3 * 5; y = x – 7; y = y + 4; Do.
Java Simple Types CSIS 3701: Advanced Object Oriented Programming.
Huffman coding Content 1 Encoding and decoding messages Fixed-length coding Variable-length coding 2 Huffman coding.
Lab5 Please submit the lab before you leave Please include at a minimum your name, the date, and the lab- program number at the top of the program as a.
Lin Chen 09/13/2011. Count words number in the file arrayUtils.h include the adding functions template int addInOrder (T* array, int& size, T value);
CS 111 – Sept. 1 Intro to data representation Binary numbers –Convert binary  decimal –Convert decimal  binary Text –ASCII and Unicode Commitment: –For.
Character Encoding & Handling doubles Pepper. Character encoding schemes EBCDIC – older with jumps in alphabet ASCII 1967 (7 bit)– Handled English, –ASCII.
Unit 2 Test: Tues 11/3. ASCII / Unicode –Each letter, symbol, etc has a # value –See ascii table (in folder) –To convert a char into its ascii value,
Lab 4 - Variables. Information Hiding General Principle: – Restrict the access to variables and methods as much as possible Can label instance variables.
1 Homework –Continue Reading K&R Chapter 2 –We’ll go over HW2 at end of class today –Continue working on HW3 Questions?
軟體實作與計算實驗 1  While-loop flow chart  Decimal to binary representations Lecture 6 While-Loop programming.
軟體實驗 Perfect Number Enumerating 虞台文. Perfect Numbers A perfect number is such that it is equal to the sum of its proper divisors, which are any divisors.
OFF = 0 ON = 1 = 63 BINARY system
Road map char data type Reading –Liang 5: Chapter 2: 2.7.4; 2.9; –Liang 6: Chapter 2: 2.7.4; 2.9 –Liang 7: Chapter 2: 2.7.4; 2.9.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI N305 Characters and Strings Functions.
INPUT/OUTPUT STATEMENT ADDITION SLIDES. Console.ReadLine() – Use to get the input (String) from user Convert string to other data type – int.Parse() 
軟體實驗:實作以二分法開根號 虞台文. The Lab Problem Write a function to compute by bisection the square root of a positive integer n given by the caller. The function’s.
FOR LOOPS "LOOP FOR A SET NUMBER OF TIMES.". FOR ( START_VALUE; END_VALUE; INCREMENT_NUMBER ) { //YOUR_CODE_HERE } So after the word "for" (in lowercase)
Chapter 8 Bit Operations By C. Shing ITEC Dept Radford University.
1 Huffman Codes Computing an Optimal Code for a Document.
軟體實作與計算實驗 1  While loop  Positive integer square root  Decimal to binary transition Lecture 6 While Loop.
CS 101 – Sept. 11 Review linear vs. non-linear representations. Text representation Compression techniques Image representation –grayscale –File size issues.
CMSC 202 Lesson 26 Miscellaneous Topics. Warmup Decide which of the following are legal statements: int a = 7; const int b = 6; int * const p1 = & a;
Potential NEALP candidates Where is the data input site?
Binary Representation in Text
Binary Representation in Text
Chapter 3 - Binary Numbering System
Topics discussed in this section:
Data Transfer ASCII FILES.
Digital Logic & Design Dr. Waseem Ikram Lecture 05
What is Binary? Binary is a two-digit (Base-2) numerical system, which computers use to process and store data. The reason computers use the binary system.
Data Encoding Characters.
Data Representation ASCII.
While Statement.
Figures & Tables from the textbook.
Digital Logic & Design Lecture 05
CS-401 Computer Architecture & Assembly Language Programming
CS 206D Computer Organization
Figure 9.1.
Figure 11-1.
Figure Overview.
Figure Overview.
Topics discussed in this section:
Presentation transcript:

軟體實驗: C-Lab7 虞台文

Lab7 Issues Lab 7-1  On-Off bits counting Lab 7-2  ACSII File Verification

ACSII Table

軟體實驗: C-Lab7 Lab 7-1

Lab 7-1: On-Off Bits Counting Write a pair of functions, bitson and bitsoff, that return the number of bits that are on and off in a file. Use the shorthand bit-manipulation operators.

Lab 7-1: On-Off Bits Counting Example: Boy.txt Good boy. Goodboy.Goodboy on off

Lab 7-1: On-Off Bits Counting Example: Boy.txt Good boy. Goodboy.Goodboy on off There are 38 on-bits and 34 off-bits in file Boy.txt.

Bit On/Off Test mask & mask & & & & & & & On Off On Off

bitson/bitsoff int bitson(char c) returns number of on-bit in c int bitsoff(char c) returns number of off-bit in c

軟體實驗: C-Lab7 Lab 7-2

Lab 7-2: ACSII File Verification Write a program that verifies that every character in its input is an ASCII character. A non-ASCII character (a character with its high-order bit set) causes an error message containing its octal code and position in the file (line number and character). We can use this program to verify that a file contains only ASCII characters before trying to compress it with our compression program (Figure 6.2.7).

ACSII Table

Lab 7-2: ACSII File Verification Example: Boy.txt Good boy. Boy.txt is an ASCII file.

Lab 7-2: ACSII File Verification Example: Girl.txt Good girl. She is a 美人. Girl.txt is a non-ASCII file. 美 人 AC = = 0254 A non-ASCII char (0254) appears at position 10 of line 2.