# 第 $N$ 次社課 $\Large{N=7}$ --- # 在開始之前 ---- # 聖誕節快樂 # :christmas_tree: :christmas_tree: :christmas_tree: ---- <!-- .slide id="fragments" --> <h3>還記得之前學了什麼嗎?</h3> <p class="fragment"><code>scanf</code></p> <p class="fragment"><code>printf</code></p> <p class="fragment"><code>if</code><span class="fragment"><code>, else if</code></span><span class="fragment"><code>, else</code></span></p> <p class="fragment"><code>for</code><span class="fragment"><code>, while</code></span><span class="fragment"><code>, do ...while</code></span></p> <p class="fragment"><code>switch &amp; case</code></p> <!-- ## 還記得之前學了什麼嗎? - `printf` - `if` - `for` - `while` - `do ...while` - `switch` --> ---- <!-- .slide id="fragments" --> <h3>還記得你們寫了什麼程式嗎?</h3> <p class="fragment">印星星</p> <p class="fragment">數石頭</p> <p class="fragment">其他的呢?</p> --- ## 正課開始~~~ ---- ### C++ ---- **C++** 是 **C** 的進化板 把許多在 **C** 繁雜的語法 簡化~~在~~再簡化 ---- <h3>例如</h3> <p class="fragment"><code>scanf</code><span class="fragment"><code> -> </code><span class="fragment"><code> cin</code></p> <p class="fragment"><code>printf</code><span class="fragment"><code> -> </code><span class="fragment"><code> cout</code></p> <p class="fragment"><code>不過基本語法都沒變</code></p> <p class="fragment"><code>if</code><span class="fragment"><code>, else if</code></span><span class="fragment"><code>, else</code></span></p> <p class="fragment"><code>for</code><span class="fragment"><code>, while</code></span><span class="fragment"><code>, do ...while</code></span></p> <p class="fragment"><code>switch &amp; case</code></p> <p class="fragment"><code>照舊</code></p> ---- #### 標頭檔 ```cpp= #include<bits/stdc++.h> using namespace std; ``` ---- #### ZeroJudge的標準輸入輸出 ```cpp= #include<bits/stdc++.h> using namespace std; int main(){ int n; while(cin>>n){ //something to do cout<<...<<'\n'; //輸出...後輸出換行 } return 0; } ``` ---- ### 簡易資料結構 ---- **陣列** ```cpp= #include<bits/stdc++.h> using namespace std; int main() { int arr[1000];//資料型態 陣列名稱 [陣列大小] arr[0] = 100; arr[999] = 1; cout << arr[0]; // 100 } ``` ---- **string** ```cpp= #include<bits/stdc++.h> using namespace std; int main() { string str; cin >> str; str = "QAQ" cout << str[0]; // Q } ``` ---- **for+陣列+string?** ```cpp= #include<bits/stdc++.h> using namespace std; int main() { string arr[1000]; for (int i = 0; i < 5; i++) { cin >> arr[i]; } for (int i = 0; i < 5; i++) { cout << arr[i] << ' '; } return 0; } ``` ---- ## 來做題目吧 --- ## ++Online Judge 介紹++ ---- <!-- .slide: data-background-iframe="https://zerojudge.tw/" data-background-interactive --> ---- ### Online Judge 是什麼? - 線上評測系統 - 會有很多題目 - 在寫完程式之後,可以丟上去,他會幫你自動檢查你的程式是否正確 ---- ### 題目的架構 1. 題目敘述 2. 輸入/輸出格式 3. 時間/記憶體容量限制 4. 測資範圍 5. 範例輸入輸出 ---- ### 怎麼看回傳的結果? - `AC (Accepted)` - 你的程式通過了這題 - `WA/NA (Wrong Answer)` - 你的程式輸出了錯誤的答案 - `TLE (Time Limit Exceeded)` - 你的程式執行太久了 ---- ### 怎麼看回傳的結果? - `MLE (Memory Limit Exceeded)` - 你的程式使用了太多空間了 - `RE (Runtime Error)` - 你的程式使用到了未定義的空間 - `CE (Compile Error)` - 編譯錯誤 ---- ## ++第二課:基礎題目練習++ ---- <blockquote cite="http://searchservervirtualization.techtarget.com/definition/Our-Favorite-Technology-Quotations"> &ldquo;程式說明:因為系統會賦予數量不一的測試資料來測驗您的程式是否正確,因此必須先以一個 while 迴圈來讀取所有的測試資料。&rdquo; </blockquote> <!-- .slide id="fragments" --> <p class="fragment">不知道有多少輸入?</p> <p class="fragment">那要怎麼處理?</p> ---- ## `EOF(End Of File)` ```cpp int main() { int n; while (cin>>n) { ... } return 0; } ``` 會一直讀到輸入結束為止 ---- ## 練習時間 ---- <!-- .slide: data-background-iframe="http://cs.cysh.cy.edu.tw/php_system/acm_statistics/basic_problem.html" data-background-interactive --> <div style="position: absolute; width: 40%; right: 0; box-shadow: 0 1px 4px rgba(0,0,0,0.5), 0 5px 25px rgba(0,0,0,0.2); background-color: rgba(0, 0, 0, 0.9); color: #fff; padding: 20px; font-size: 20px; text-align: left;"> <h2><a href="http://cs.cysh.cy.edu.tw/php_system/acm_statistics/basic_problem.html">ZeroJudge 的練習題單</a></h2> <p>如果看不到這頁就是他被擋下來ㄌ,自己點連結進去看ㄅ</p> </div> --- ## Credit : - Nkl5RDZZZVg1N2F0 - hq8398 - SorahISA
{"metaMigratedAt":"2023-06-15T02:49:34.866Z","metaMigratedFrom":"YAML","title":"20191225_HLHS_Infor","breaks":true,"slideOptions":"{\"allottedMinutes\":30,\"slideNumber\":true,\"theme\":\"solarized\",\"transition\":\"slide\"}","contributors":"[{\"id\":\"50520b8d-a2d3-4e49-b39e-7b53e571cadc\",\"add\":7418,\"del\":2949},{\"id\":\"e573a1ba-d69b-44a7-a0d5-9d817fb786cc\",\"add\":8,\"del\":8}]"}
    161 views
   Owned this note