<style> html, body, .ui-content { background-color: #333; color: #ddd; } body > .ui-infobar { display: none; } .ui-view-area > .ui-infobar { display: block; } .markdown-body h1{ color: #9CCEF2; } .markdown-body h2, .markdown-body h3{ color: #B1D6CA; } .markdown-body h4, .markdown-body h5, .markdown-body h6 { color: #ddd; } .markdown-body h1, .markdown-body h2 { border-bottom-color: #ffffff69; } .markdown-body h1 .octicon-link, .markdown-body h2 .octicon-link, .markdown-body h3 .octicon-link, .markdown-body h4 .octicon-link, .markdown-body h5 .octicon-link, .markdown-body h6 .octicon-link { color: #fff; } .markdown-body img { background-color: transparent; } .ui-toc-dropdown .nav>.active:focus>a, .ui-toc-dropdown .nav>.active:hover>a, .ui-toc-dropdown .nav>.active>a { color: white; border-left: 2px solid white; } .expand-toggle:hover, .expand-toggle:focus, .back-to-top:hover, .back-to-top:focus, .go-to-bottom:hover, .go-to-bottom:focus { color: white; } .ui-toc-dropdown { background-color: #333; } .ui-toc-label.btn { background-color: #191919; color: white; } .ui-toc-dropdown .nav>li>a:focus, .ui-toc-dropdown .nav>li>a:hover { color: white; border-left: 1px solid white; } .markdown-body blockquote { color: #bcbcbc; } .markdown-body table tr { background-color: #5f5f5f; } .markdown-body table tr:nth-child(2n) { background-color: #4f4f4f; } .markdown-body code, .markdown-body tt { color: #eee; background-color: rgba(230, 230, 230, 0.36); } a, .open-files-container li.selected a { color: #5EB7E0; } </style> ###### tags: `tgirc早修book` # Ch.00 題目練習 ## 輸出 <font color="FEA0A0">**題目**</font> 1. [Zerojudge d483: hello, world](https://zerojudge.tw/ShowProblem?problemid=d483) :::spoiler <font color="FEA0A0">**題解**</font> 1. [Zerojudge d483: hello, world](https://zerojudge.tw/ShowProblem?problemid=d483) ```cpp= #include <iostream> using namespace std; int main(){ cout<<"hello, world"; return 0; } ``` 單純的輸出而已,有錯的可能是輸出的格式錯誤。 可以直接複製範例測資,就能確保格式正確了。 ::: ## 輸入 <font color="FEA0A0">**題目**</font> 1. [Zerojudge a001: 哈囉](https://zerojudge.tw/ShowProblem?problemid=a001) :::spoiler <font color="FEA0A0">**題解**</font> 1. [Zerojudge a001: 哈囉](https://zerojudge.tw/ShowProblem?problemid=a001) ```cpp= #include <iostream> using namespace std; int main(){ string s; cin>>s; cout<<"hello, "<<s<<"\n"; return 0; } ``` 相較於上題多了個輸入,透過 string 宣告一個字串 s,再進行輸入即可。 輸出時先輸出題目要求的 `hello, `,再輸出裝載輸入訊息的變數 s :::