1 / 21

ACM

ACM. 1. ACM ICPC NCPC 介紹 2. Onlinejudge 使用教學 3. 程式寫作習慣 基本 IO 介紹 …………………………… by wts31017. 什麼是 ACM?. ACM ( Association of ComputingMachinery ) 是 美國計算機協會 的簡稱 , 創立於 1947 年 , 是史上第一個計算機科學與教育學會 , 其網站中 Onlinejudge ( 線上判題 ) 擁有龐大的題庫可供練習 , 可以讓你寫程式能力大增喔! 網址 http://acm.uva.es/. ICPC NCPC.

Télécharger la présentation

ACM

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ACM 1. ACM ICPC NCPC介紹 2. Onlinejudge使用教學 3. 程式寫作習慣 基本IO介紹 ……………………………by wts31017

  2. 什麼是ACM? ACM(Association of ComputingMachinery) 是美國計算機協會的簡稱, 創立於1947年,是史上第一個計算機科學與教育學會,其網站中Onlinejudge(線上判題) 擁有龐大的題庫可供練習,可以讓你寫程式能力大增喔! 網址http://acm.uva.es/

  3. ICPC NCPC • ICPC(International Collegiate Programming Contest ,ACM國際大學生程式設計競賽) • NCPC(全國大專程式能力競賽) ※一路過關斬將,表現優異者不但能代表學校,更可以代表國家去跟世界上其他好手比賽(國手),未來必定會成為業界搶手的人才喔!

  4. ICPC基本規則 • 以學校名義參賽團體報名(每組三人) • 比賽時間:5小時左右 • 題目:不等 • 答錯懲罰:增加解題時間(是送出通過後的解題時間) • 勝負判定:以解出題目數量優先,若有解題數一樣的狀況就比時間(時間少的獲勝)

  5. Onlinejudge使用教學 • 介紹:Onlinejudge 線上判題 • 網址:http://icpcres.ecs.baylor.edu/onlinejudge/index.php • 步驟一: 輸入上列網址

  6. 步驟二:在網頁左方點Register • 步驟三:輸入申請資料(下圖)

  7. 步驟四:註冊成功要去信箱開通帳號 • 步驟五:到信箱開啟郵件

  8. 實際操作

  9. 判題結果說明 • Accept (AC) 接受(通過) • Presentation Error (P.E.) 格式錯誤 • Wrong Answer (WA) 錯誤答案 • Time Limit Exceeded (TLE) 超過時間 • Memory Limit Exceeded (MLE) 超過記憶體上限 • Output Limit Exceeded (OLE) 超過輸出上限 • Compile Error (CE) 建置錯誤 • Submission Error (SE) 提交錯誤 • Runtime Error (RE) 執行錯誤 • Restricted Function (RF) 使用禁止函式

  10. 程式寫作習慣 • 1.變數宣告要有意義 正確示範 int number1,number2,answer,count=0 ; if(count==0) { answer=number1*number2; printf(“%d\n”,answer); } 變數標明清楚簡單明瞭 錯誤示範 Int XD,XXD,XDD,XXDD=0 ; if(XXDD==0) { XDD=XXD*XD; printf(“%d\n”,XDD); } 誰看的懂阿@@...神經病才幫你debug

  11. 程式寫作習慣 • 2.程式碼易讀性(縮排與不省略) 錯誤示範 If(k==0) k++; 雖然這樣寫OK但是避免萬一盡量別用 for(…;…;…) { for(…;…;…) { for(…;…;…) { k++; } } }//誰是誰的迴圈阿!? 正確示範 If(k==0) { k++; } for(…;…;…) { for(…;…;…) { for(…;…;…) { k++ ; } } }一層一層清晰明瞭

  12. 程式寫作習慣 • 3.註解 單行註解 // 區段註解 /**/ #if 0 #endif • 4.變數處理 a.盡量不要使用global變數(寫在main外面的) ,該傳的變數使用副程式 b.要注意數值範圍,不然可能造成array超過記憶體宣告空間 有可能會影響到存放其他變數的記憶體 • 5.分號 括號 不要漏掉 • 6.盡量不要抄別人的code,想法可以參考,但要自己寫才會進步

  13. 變數資料型態 取自2008寒訓講義

  14. 基本IO介紹 • 數值輸入輸出 C語言數字輸入 int num; scanf(“%d”,&num); 多筆資料 scanf(“%d%d”,&num1,&num2); C++數字輸入 int num1,um2; cin>>num1; 多筆資料 cin>>num1>>num2; 記得C++要用 #include<iostream> using std::cin; using std::cout 或 #include<iostearm> using namespace std; C++數字輸入 int num; cout<<num<<endl; cout<<num<<“\n”; 多筆資料 cout<<“數字1是”<<num1<<“數字2是”<<num2<<endl; C語言數字輸出 int num; printf(“%d\n”,num); printf(“%d%d”,num1,num2);

  15. 基本IO介紹 記得C++要加入 #include<iostream> using namespace std; • 字元輸入輸出 • 字串輸入輸出 C語言字元輸入輸出 char c; c=getchar(); //輸入一個字元存到c printf(“%c”,c); //把c存的字元印出來 C++字元輸入輸出 char c; c=cin.get(); //輸入一個字元存到c cout<<c; //把c存的字元印出來 C語言字串輸入輸出 char s[100]; gets (s); //輸入一整串字存到s printf(“%s”,c); //把c存的字串印出來 C++字串輸入輸出 char s[100]; cin.getline(s,100); //輸入一個字元存到c cout<<s; //把c存的字串印出來 /*cout真是萬用阿~~*/

  16. 基本IO介紹 • 欄寬 補空白 對齊 C語言寫法: char a[]="abcd"; printf(“%10s\n”,a); //欄寬為10 置右對齊 printf(“%-10s\n”,a); //欄寬為10 置左對齊 printf(“%010s\n”,a); //欄寬為10 置右其餘補0 C++寫法: char a[]="abcd"; cout.width(10); //欄寬 10 cout<<left<<a<<endl; //置左 cout.width(10); //欄寬 10 cout<<right<<a<<endl;//置右 cout.width(10); //欄寬 10 cout.fill(‘0’); //補0 cout<<right<<a<<endl;//置右 左邊補0也可以這樣寫 #include<iomanip> using std::setw; cout.fill('0'); cout<<setw(10)<<a<<endl;

  17. 基本IO介紹 • 小數點精確到第幾位 C語言寫法 float i=3.141592; printf(“%f\n”,i); //正常 printf(“%.1f\n”,i); //小數一位 printf(“%.4f\n”,i); //小數四位 C++寫法 float i=3.141592; cout << setprecision(3) << i << endl ; //包含整數精確3個數字 cout << setiosflags( ios :: fixed )<<setprecision(3)<<i; //小數以下精確三個數字

  18. 小叮嚀 • C語言 • #include<stdio.h> • C++ • #include<iostream> • using namespace std; • //千萬別忘記加

  19. CMD 測資處理 • windows的cmd檔案IO的功能 • 指令: • test<input.txt <enter> 從檔案input讀入test.exe執行 • test>output.txt <enter> 把你在test.exe所print的結果存到output.txt中 混用法 test<input.txt>output.txt <enter>

  20. 練習題 基本題 10055 10071 272 進階題 591 541 579

  21. 相關網站整理 • ACM 官方網站 http://acm.uva.es/ • ACM onlinejudge • http://icpcres.ecs.baylor.edu/onlinejudge/index.php • ACM討論區(提供測資) http://online-judge.uva.es/board/index.php By wts31017

More Related