信息学奥赛一本通 2066:【例2.3】买图书
生活随笔
收集整理的這篇文章主要介紹了
信息学奥赛一本通 2066:【例2.3】买图书
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
【題目鏈接】
ybt 2066:【例2.3】買圖書
【題目考點】
1. 算術表達式
2. 輸出浮點數a保留x位小數
printf(%.xf, a);
cout<<fixed<<setprecision(x)<<a;
【題解代碼】
解法1:用cin, cout
#include<bits/stdc++.h> using namespace std; int main() {double n, m;cin >> n >> m;cout << fixed << setprecision(2) << n-m*0.8;return 0; }解法2:用scanf, printf
#include<bits/stdc++.h> using namespace std; int main() {double n, m;scanf("%lf %lf", &n, &m);printf("%.2f", n-m*0.8);return 0; }總結
以上是生活随笔為你收集整理的信息学奥赛一本通 2066:【例2.3】买图书的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 信息学奥赛一本通(1226:装箱问题)
- 下一篇: 信息学奥赛一本通 1133:输出亲朋字符