String-Exercises.docx 文字處理 String Manipulation: char s[100]; <str-ex01a> s[i] Q: n=? 0. Q: enter text: Chan Tai Man A: s[3]='n', "Chan"

Similar documents
台北縣立江翠國民中學九十八學年度第二學期第三次定期考查七年級英語科試卷 P1 七年 ˍˍ 班座號 ˍˍ 姓名 :ˍˍˍˍˍˍ

汉字的笔画. 学习目标 Objective. 学习基本笔画和复合笔画 Learn basic and compound strokes

Shatin Tsung Tsin Secondary School Geography S1 Teaching Schedule Topics

London Marathon 伦敦马拉松

平成 29 年度金沢学院大学入学試験問題 3 月 17 日 ( 金 ) Ⅰ 注意事項解答用紙に 英語 と記入 マークしてから解答してください 問題は1ページから8ページまであります 問題は持ち帰ってもよいですが コピーして配布 使用するのは法律で禁じられています

語文類 ( 一 ) 專業科目 ( 一 ) 英文閱讀能力測驗 注意事項 准考證號碼 :

The Boat Race 划船赛. The Oxford and Cambridge Boat Race 牛津剑桥划船赛. Read the text below and do the activity that follows.

Swimming Star 泳坛新星 1

The 3rd Hong Kong Games Dynamic Moments Photo Contest. Prospectus

Return of the Heroes 奥运健将凯旋归来

The 2009 Snooker World Championship 2009 年世界台球锦标赛

The Hong Kong Polytechnic University Flags of Harmony and Unity. Reminder for Participants

The Snooker World Championship

Jet Li 李连杰. China s highest-earning star 中国收入最高的影星. Read the text below and do the activity that follows. 阅读下面的短文, 然后完成练习 :

The English Premier League

Hong Kong Contract Bridge Association Ltd.

Chinatown Broadway Street Design Summary of Public Comment Workshop #2

常葉大学短期大学部一般入学試験前期日程 1. 試験開始の合図があるまで 問題用紙 解答用紙の中を見てはいけません

103 年公務人員特種考試關務人員考試 103 年公務人員特種考試身心障礙人員考試及 103 年國軍上校以上軍官轉任公務人員考試試題

Comparison between QuikSCAT and Ocean Tower Wind Measurements in Taiwan Strait. Min-Chih Huang 1 Yueh-Hao Liu 2 ABSTRACT

Athletics World Championships: 世界田径锦标赛

HONG KONG SWIMMING COACHES ASSOCIATION

2018 TLGPA & Royal Open

2016 CTBC LADIES OPEN. Tournament Information

Hollywood s Leading Lady. 妮可基曼在兩年多前以紅磨坊一片贏得她生命中第二座金球獎以及第一個奧斯卡提名, 豔冠群芳, 躍升為好萊塢一線實力派女星 最新力作 冷山 (Cold

Number Bases LESSON ONE By John Owen. Computer Science

灣仔運動場 Wan Chai Sports Ground, Hong Kong 指定完成時間. Finish Time. 06:30am 15 分鐘. 06:45am 30 分鐘

Ballroom Dancing 国标舞

Lesson 5. Climbing the Wall. Part 1. 一 字彙填空與詞類變化 goal 1. Patrick has made up his mind to reach his g l of being a famous actor.

平成 30 年度一般入学試験 B 日程学科試験問題 ( コミュニケーション英語 Ⅰ Ⅱ)

Physical Education Section Curriculum Development Institute Education Bureau The Government of the Hong Kong Special Administrative Region 2014

2017 Hong Kong Marathon Swimming cum Open Water Swimming Competition Series (Part 1) 2017/18

ELECTROSTATIC DISCHARGE (ESD) TESTING REPORT

Certificate of Accreditation

この英語の試験は 文法 / 語彙 / 長文読解と聞き取りの 2 つの部分からなり 時間は全部で 100 分です ( 説明を含む ) 試験開始から 70 分で文法 / 語彙 / 長文読解 そして残りの約 30 分で聞き取りテストを行います 受験番号氏名

2019 SAMPO Ladies Open

A Decision Making Method using Wants Chain Analysis for Business-model Design

航空季節優惠及附加 - 請將此項 (1) 酒店列表價格 + (2) 應付稅項 = 便可計算出閣下之自由行總價 Resort Rate from below table + Applicable Tax = Total Package Rate

承 (Cherng G. Ding) 論文著作目錄

2016 ASIA FOOSBALL CLASSIC. 潭 子精密盃 亞洲 手 足球經典賽 2016 Apr 8-10

HOW DO I REGISTER FOR SKATE SASKATOON PROGRAMS?

年度全港青少年棒球聯賽 Hong Kong Youth Baseball League U14 組競賽附則. U14 - Supplementary Rules & Regulations

A. 次の問い ( 問 1~ 問 3) において, 下線部の発音がほかの三つの場合と異なるものを, それ B. 次の問い ( 問 4, 問 5) において, 第一アクセント ( 強勢 ) の位置がほかの三つの場合と異な ぞれ 1~4 の中から一つずつ選びなさい

HONG KONG ARTS FESTIVAL

Hong Kong Football Club Junior Squash Open 2018

The Hong Kong Radio Control Soaring Society 香港遙控滑翔飛行協會

Sup dude! U gotta see this

始まりのブザーが鳴るまで問題冊子 解答用紙に手を触れずに

The 27th Annual Canadian National Kungfu Championship 2016

( 工 経営情報 国際関係 人文 応用生物 生命健康科 現代教育学部 )

2016 Consortium for Computing Sciences in Colleges Programming Contest Saturday, November 5th University of North Carolina at Asheville Asheville, NC

起步前 Before Start. 起步 Start. 衝線後 After Finish 參賽者應自行決定自身之健康情況是否適合比賽, 倘若於比賽日前感到身體不適, 建議請教醫生意見後, 方可參賽 於比賽期間如有任何不適, 請立即向附近的工作人員求助

2013 Fall & Winter CAGT NEWSLETTER. Volume 6 Issue Fall & Winter

* 水試開始時間為下午 2 時正 熱身時間為下午 1 時 15 分 -1 時 45 分 *Swimming Test will start at 2 p.m. Warmup time will be 1:15p.m.- 1:45p.m.

Club s Homepage Use this feature to return the club s website.

St. Louis School Internal Test and Exam Syllabus (Final Examination)

Resource Sharing in the Japanese Libraries. Dr. Nobuhiko Kikuchi Kansai-kan of the National Diet Library

2 人成行 GV2 訂位代號 Booking Class : N * 所有機票訂位代號及附加費, 請參閱尾頁國泰 / 港龍沖繩機票附加費表 * *Please refer to the last page for booking class & airfare surcharge*

Improving the Failure Rate of Holding Pressure of Gas Pipeline by 6σ Method 品管控制氣體管路保壓失敗率之研究

Hong Kong Ladies Open 2015 Tournament Information

Rotel RX-1052 RS232 HEX Protocol

Survey on Professional Baseball

Inkling Fan Language Character Encoding Version 0.3

Kulo Wing Chun Leung Jan 22 Sansau Workshop UTS KFC 17/11/2012 古勞詠春梁贊二十二式

Pointing and Calling 指差呼稱 Reduces Human Error 減少人為失誤

姓名劉醇星職稱副教授學歷成功大學電機博士辦公室 5504 電話 (06) 轉 電郵 半導體 顯示器元件研發處處長

[æ] [ə] 音标入门讲解一 元音. ( 一 ) 单元音 (1) 前元音 :[i:] [i] [e] [æ] (2) 中元音 :[ə:] [ə] 发音组合 : e ee ea ie ei 代表单词 : me he we even. 发音组合 : i 代表单词 : sit bit kick pick

NCSS Statistical Software

體育及康樂課程 SPORTS & RECREATION

GUIDE ENTRY MAILIAO HARBOR ADMINISTRATOR CORP.

比賽時間流程及地點 Key Times and Locations

2018 年綜合處方一覽表. Centers Plan for Medicare Advantage Care (HMO)

2015 CTBC LADIES OPEN. Tournament Information

Fantasy Golf Made Easy

Sam: I joined a basketball camp and learned some useful skills.

Women's Open Heptathlon

燃油附加費各地相關稅項及附加費注意事項 : 機位及酒店確實後需付全數只適用於香港及中國市場機票或酒店發票簽發後, 恕不退款或更改價目如有任何更改, 恕不另行通告. Room Type

2 月份學科活動 2018 年 2 月號 科學科 2 月 1 及 7 日 攤位遊戲 全校 中文科 2 月 5 及 26 日 圖書活動 全校 節日 / 科目 舉行日期 活動 對象. 總編輯 : 俞碧珍主任電腦排版 : 茄雲編輯 :Samuel, Rory, 鄭嘉敏老師

Dive Sheets & Running Events Meet Management Software Tutorial for EZMeet Version 3.1 revised 2/4/2006

2017 FIE Women s Epee World Cup (Suzhou)

The NIKE Cup Hong Kong Five 2018

红宝书 练习题及答案详解 必考词 考研英语词汇 ( 必考词 + 基础词 + 超纲词 ) 第三节. (Unit 15 Unit 21; 第 99 页 147 页 ) 练习一 : 词汇与搭配 通用网址 : 红宝书. 红宝书网址 :

Free Admission to Masters of Hong Kong 2017 (An International Show Jumping Equestrian Event)

零售債券風險程度一覽表 (2018 年 4 月 2 日更新 ) Retail Bond Risk Rating (Updated on 2 Apr 2018)

Lexi Srisuwan. (803)

TOURNAMENT OF THE DAY

1. (a) (i) 0.049, 0.39, 0.4, 0.409, B1 for correct order. (b) B1 for (a) B1 for (b) B1 for 0.08.

Club s Homepage Welcome Club Calendar Logout Add a Request Play Date Requested Time Hole Selection # of Tee Times Break Link

97 修訂綱要本表為常用 2000 字詞, 其中畫底線者為國民中小學最基本之 1200 個字詞 附錄四 : 參考字彙表

Report on Transportation Survey Conducted by HKUST Staff Association (Feb 2016)

SUUNTO CORE USER GUIDE

Dear Colleagues, In this HKUST Staff Association News, we would like to bring to you:

Challenge! Open Governance 2017 Application Form for Citizens & Students

Swimming Programme by Harry Wright International. The Premier Swim School Mid Term Swim Camp , 16, 18 & 19 October 2018

Name: 1. Wow! Watch this video to find out what we re going to be learning about in this Project:

APPLICATION NOTE. OJ-DV Modbus protocol. OJ Drives A DRIVES PROGRAMME DEDICATED TO VENTILATION SOLUTIONS E 03/18 (PDJ) 2018 OJ Electronics A/S

国際スポーツクライミング協会 INTERNATIONAL FEDERATION OF SPORT CLIMBING IFSC

INDEX 目錄 P.4 P.5 P.6 P.7 P.8-9 P P P.16 P.17 P.18 P.18 P.19 P P P P P P P P.

MATHCOUNTS. Raytheon National Competition Sprint Round Problems 1 30 DO NOT BEGIN UNTIL YOU ARE INSTRUCTED TO DO SO. Name.

AUTOGENOUS DEVICES 气焊设备

Transcription:

文字處理 String Manipulation: char s[100]; <str-ex01a> s[i] Q: n=? 3 Q: enter text: Chan Tai Man A: s[3]='n', "Chan" Q: n=? 0 Q: n=? 7 A: s[0]='c', "C" A: s[7]='i', "Chan Tai" <str-ex01b> '\0' Q: enter text: Chan Tai Man Q: n=? 7 A: Chan Tai Q: n=? 3 A: Chan <str-ex02a> s[i] Q: enter text: ChanTai C h a n <str-ex03> a-z, aeiou, 0-9 Q: enter text: Chan Tai Man A: 10 letters, 4 vowels 2 spaces, 0 digits 大楷 (3), 小楷字母 (7), 數字 (0), 其他 (2) <str-ex05> strcmp char t[20], s[20]="chan TM"; Q: Enter text(t) : chan A: strcmp(s,t)= 1 strcmp(t,s)=+1 Q: Enter text(t) : CHAN A: strcmp(s,t)=+1 strcmp(t,s)= 1 <str-ex06b> surname Q: Enter text : Cheung Three A: Cheung A: Chan 1 <str-ex01c> '\0' ½,¼,⅛ Q: enter text: Chan-Tai-Man A: 12 Chan-Tai-Man 6 Chan-T 3 Cha 1 C <str-ex02b> s+i, strncpy Q: enter text: Chan-Tai-Man Chan-Tai-Man han-tai-man C an-tai-man Ch n-tai-man Cha : : n Chan-Tai-Ma <str-ex04> a-z ( 只輸出字母 ) Q: enter text: Chan [Tai]+Man ChanTaiMan (10) Q: enter text: $C%h_an7? Chan (4) <str-ex06a> surname (4 char) A: Chan Q: Enter text : Cheng Hong Tai A: Chen Q: Enter text : Lo Tai Man A: Lo T Q: Enter text : Lee Four A: Lee Q: Enter text : Lo Wai Man A: Lo

<str-ex07a> file + surname 1A01 Chan 1A02 Cheng <str-ex07b> surnames in file Chan = 69 Li/Lee = 58 Wong = 37 Cheung = 25 <str-ex08> reverse Q: Enter text : A: dcba A: nam iat nahc <str-ex11> anagram + freq[] Q: Enter text(s) : time Enter text(t) : item Q: Enter text(s) : timer Enter text(t) : item A: No www.ssynth.co.uk/~gay/anagram.html school2011e.txt 1A01 Chan Tai Man M M 1A02 Cheng Wai Yip M L <str-ex10> palindrome 廻文 Q: Enter text : A: No Q: Enter text : abcba Q: Enter text : ab cb A <str-ex09> word count A: 3 words Q: Enter text : Chan Tai-Man, John A: 4 words Q: Enter text(s) : act Enter text(t) : cat Q: Enter text(s) : Mother-in-law Enter text(t) : Woman Hitler Q: Enter text(s) : Funeral Enter text(t) : Real Fun <str-ex12a> idno (check format) Q: HK id card#: A1234 A: Invalid Q: HK id card#: A123456(7) A: Valid Q: HK id card#: 0123456(7) A: Invalid <str-ex13> swapping characters Q: enter text: Chan Tai Man 012345678901 Q: swap s[x] & s[y] x=? 2 y=? 5 A: ChTn aai Man <str-ex12b> idno (check digit) Q: HK id card#: A123456 A: A123456(3) Q: swap s[x] & s[y] x=? 7 y=? 0 A: ihtn aac Man 2

<str-ex14> position of substring Q: source string: banana target string: na A: 2, 4 Q: source string: banana target string: nba A: not found <str-ex16> Initials Q: 姓名 name? chan tai man A: Chan Tai Man A: 簡寫 Chan TM A: 簡寫 TM Chan A: tai man, chan Q: 姓名 name: Chan Ho A: Chan H <str-ex18> Random Names generator Surname: 陳, 李, 張, 鄭, 王, 何,... Given name: 大文, 小明, 偉業, 成功... 陳大文, 李小明, 鄭成功, <str-ex15> MC checking Model Ans: ABCDABCD Student Ans: AABBCCDD Score: 2 Student Ans: Score: 4 ABCDDCBA <str-ex17> 中英對照 Q: name? chan tai man A: 陳 Q: name? lee km A: 李 Q: name? cheung yc A: 張 Q: name? wong ww A: 黃 <str-ex19> Eliminate blank spaces Q: 姓名 : Chan Tai Man A: Chan Tai Man <str-ex20> re-arrange the alphabets char s[]="house"; Q: Word Sequence: 11354 A: Error! Q: Word Sequence: a1354 A: Error! Q: Word Sequence: 1354 A: Error! Q: Word Sequence: 21354 A: ohues <str-ex22> int to string/char Q: Level (1-7): 4 Class (A-D): a No. (1-40): 9 A: Class no. = 4A09 <str-ex21> Hangman char words[10]="secret"; char guess[10]= "------"; Hint: 秘密 Q: guess (1)? a A: ------ Q: guess (2)? e A: -e--e-... <str-ex23> 文字輸入, 文字輸出 Q: class number: 4109 A: 4A09 Q: class number: 4AB9 A: Error Q: class number: 6540 A: 6E40 3

<str-ex23> char s[10]=""; 輸出 1: 輸出 2: 輸出 3: a a a b b ab c c abc d d 輸出 6: rotate-left 輸出 7: rotate-right bcda cdab dabc dabc cdab bcda <str-ex25> parity check (8-bit) Q: Even or Odd: E Q: enter bit pattern: 10101010 A: parity bit is 0 <str-ex27> HKID 檢查數位 ( 函數 ) Q: ID card no.: A101010A A: valid 合法 Q: ID card no.: A101010 A: invalid 不合法 Q: ID card no.: 0101010X A: invalid 不合法 <str-ex28> check digit of ISBN Q: enter ISBN: 962001006X A: valid 輸出 4: kill-left bcd cd d 輸出 5: kill-right abc ab a <str-ex24> Split line into words Q: enter text: this is a test. A: (1)this (2)is (3)a (4)test <str-ex26> parity check (8-bit) Q: Even or Odd: E Q: enter bit pattern + parity bit : 101010101 A: invalid int checkformat(char id[]) 1. length=8 2. first char = alphabet (A-Z) 3. 6 digits (0-9) 4. last digit (0-9,A) int validatecheckdigit(char id[]) 1. call checkformat(id) 2. sum = 58 9 + 3. sum / 11 <str-ex29> Visa IBM check Q: Visa: 1234678912346789 A: valid <str-ex30> Roman Dec Roman Roman: V+III A: 5+3=8 V+III=VIII <str-ex31> string to int Q: page no.s: 1,3,7-10,15 A: 1 3 7 8 9 10 15 Roman: XI+XV A: 11+15=26 XI+XV=XXVI <str-ex32> char s[]=" A B C "; gets(s); Ltrim(s); puts(s); "A B C " Rtrim(s); puts(s); " A B C" Alltrim(s); puts(s); "A B C" 4

Master mind (Red,Yellow,Green,Magenta) Rules of the game 1. The computer randomly generates a set of secret code which consists of 4 colored code pegs (RYGM): 2. The color code pegs may be duplicated. e.g. RGYY. 3. You, as the player, attempt to decode the secret code. 4. If your guess of a peg is of correct color and correct position, then a black indicator peg (represented by B) will be shown. 5. If your guess of a peg is of correct color, but wrong position, then a white indicator peg (represented by W) will be shown. 6. With the black and white indicator pegs, you can improve your next guesses. For example, the secret code is BGYY Your guess is MGYM yields BB Your guess is MGYB yields BBW 7. The number of trials that you can attempt depends on the level of difficulty that you have selected. 8. You win the game if you decode all 4 colored code pegs. i.e. when 4 black indicator pegs (BBBB) are shown. Master Mind 假設謎底是 "FACE", 執行結果如下 : 以 ABCDEF 代表 6 種顏色 O 表示 : 字母正確, 位置正確 ;( ) X 表示 : 字母正確, 位置不正確 ( ) 嘗試 1: AB 嘗試 1: ABCD 輸入錯誤提示 : OX 嘗試 4: aacc 提示 : OO 嘗試 1: ABXY 輸入錯誤 嘗試 2: ACEF 提示 : XXXX 嘗試 5: cafe 提示 : OOXX 嘗試 1: ABCDEF 輸入錯誤 嘗試 3: acef 提示 : XXXX 嘗試 6: face 提示 : OOOO 全對! "ABCDEFGHIJKLMNOPQRSTUVWXYZ" enkey = "XCISGTUDMOAEZYVKRHQJWNBPLF"; // 編碼 encoding key dekey = "KWBHLZERCTPYIVJXSQDFGOUANM"; // 解碼 decoding key 5

Encoding process: Decoding process: Letter A X ( i.e. enkey[1] ) Letter X A ( i.e. dekey[24] ) Letter B C ( i.e. enkey[2] ) Letter C B ( i.e. dekey[3] ) Letter C I...... Letter I C...... Advanced: enkey dekey 15. Password checking: ( 三次機會 max 3 trials) char userid[][]={"cs101","cs102","cs103","cs104","cs105"}; char password[][]={"pig","dog","tiger","cat","monkey"}; Q: enter user id: cs101 Q: enter user id: cs101 Q: enter password: cat Q: enter password: lion A: Incorrect! 2 chance(s) left! A: Incorrect! 1 chance(s) left! A: Login (un)successful! Table Of Content/30 char per line display: Enter first word: turtle Enter page number: 153 123456789 123456789 123456789 turtle...153 7. 從簡單文字算式計算答案 char arith[20]="3+2-1"; gets(arith); Q: 3+2-1 A: 4 Q: 3 2+1 A: 7 2. Password checking userid[]: cs101, cs102,... cs105 password[]: pig, dog, tiger, cat, goat Q: UID: cs101 PWD: dog A: incorrect! 9. Q: enter number: 1234567 A: reverse: 7654321 Q: enter number: 1234 A: reverse: 4321 Q: enter number: 123 A: reverse: 321 11. Letter count: Q: Enter text: I like C programming! A: Statistics: A(1), C(1),... I(3), M(2),... 6. 二進制轉十進制 Binary to decimal (d=d*2+i) Q: Binary: 1010 A: Decimal = 10 10. Q: enter number: 1234567 A: 1,234,567 Q: enter number: 1234 A: 1,234 Q: enter number: 123 A: 123 11. Counting vowels (aeiou) 12. int to string: 0->"000", 10->"010" 6