# 輸入輸出 ## 輸入cin: cin 加上兩個大於 ```cpp cin >> n ``` ### 多個輸入 ```cpp cin >> a >> b >> c ``` ### EOF ```cpp while(cin >> a >> b >> c) ``` ## 輸出cout: cout 加上兩個小於 ```cpp cout << "Hello world" << '\n'; ``` ```cpp int n=10; cout << "n=" << n << "." << '\n'; ``` :::info 小於之間輸出的資料只能是相同的型態 ::: ### 輸出小數點 引入函式庫 ```cpp #include<iomanip> ``` 利用`fixed`跟`setprecision()`控制小數後幾位 ```cpp cout << fixed << setprecision(2) << num << '\n'; //小數點後二位 cout << fixed << setprecision(3) << num << '\n'; //小數點後三位 cout << fixed << setprecision(4) << num << '\n'; //小數點後四位 cout << fixed << setprecision(5) << num << '\n'; //小數點後五位 ``` ###### tags: `中和高中`