Editorial for [Làm quen OJ]. Bài 2. Print Number
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
Bài này cần khai báo Y là long long nếu khai báo int sẽ bị tràn khi lưu giá trị trong khoảng -10^18<=Y<=10^18
In ra F và D cần in chính xác số lượng chữ số sau dấu phẩy mà đề bài yêu cầu, dùng fixed << setprecision như trong slide lý thuyết
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;
int main(){
int x;
long long y;
char c;
float f;
double d;
cin >> x >> y >> c >> f >> d;
cout << x << endl;
cout << y << endl;
cout << c << endl;
cout << fixed << setprecision(2) << f << endl;
cout << fixed << setprecision(9) << d << endl;
return 0;
}
Comments