[Làm Quen OJ]. Bài 19. Phần thập phân

View as PDF

Submit solution

Points: 1.00 (partial)
Time limit: 1.0s
Memory limit: 256M
Input: stdin
Output: stdout

Author:
Problem source:
28Tech
Problem type
Allowed languages
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch

Cho số thực F, nhiệm vụ của bạn hãy in ra phần thực và phần nguyên của F


Đầu vào

Dòng duy nhất chứa số thực F


Ràng buộc

-10^6<=F<=10^6


Đầu ra

Dòng 1 in ra phần nguyên Dòng 2 in ra phần thực với 2 số sau dấu phẩy


Ví dụ

Input 01
9.73
Output 01
9
0.73

Comments

Please read the guidelines before commenting.



  • 0
    heo2912013  commented on Feb. 22, 2025, 6:22 a.m.

    THAM KHẢO C++ NHA

    include <bits/stdc++.h>

    define ll long long

    using namespace std; double n; int main() { cin>>n; ll m=(ll) n; cout<<m<


  • 0
    bennie15025_meow  commented on Feb. 11, 2025, 1:14 p.m.

    include<bits/stdc++.h>

    using namespace std; long double f; int main() { cin>>f; long long x=f; cout<<x<


  • -1
    VDev  commented on Jan. 18, 2025, 12:29 p.m.

    FULL AC

    #include <bits/stdc++.h>
    #include <iomanip>
    #include <cmath>
    #include <climits>
    #define ll long long
    using namespace std;
    ll a[10000011];
    ll cnt = 0, s = 0, mark[10000011], chan = 0, le = 0;
    
    int main(){
        double n;
        cin >> n;
        ll m = (ll) n;
        cout << m << endl;
        cout << abs(m - n);
        return 0;
    }
    

  • -1
    LONGPHAN  commented on Oct. 27, 2024, 12:34 p.m.

    include <bits/stdc++.h>

    using namespace std; int main() { iosbase::syncwith_stdio(false); cin.tie(NULL); double F; cin >> F; int PhanNguyen = floor(F); double PhanThapPhan = F - PhanNguyen; cout << PhanNguyen << endl; cout <<PhanThapPhan << endl; return 0; }


  • -1
    LONGPHAN  commented on Oct. 27, 2024, 12:34 p.m.

    include <bits/stdc++.h>

    using namespace std; int main() { iosbase::syncwith_stdio(false); cin.tie(NULL); double F; cin >> F; int PhanNguyen = floor(F); double PhanThapPhan = F - PhanNguyen; cout << PhanNguyen << endl; cout <<PhanThapPhan << endl; return 0; }


  • -1
    Try_hardxx  commented on Oct. 27, 2024, 4:13 a.m.

    include<bits/stdc++.h>

    using namespace std;

    int main(){ double a,b,c,d; cin >> a; cout <<(long long)a <<'\n'; cout <<setprecision(2)<

    }


  • 1
    fuchs  commented on May 27, 2024, 7:05 p.m.

    import java.util.Scanner;

                public class Main {
                    public static void main(String[] args) {
                        Scanner scanner = new Scanner(System.in);
    
                        double F = scanner.nextDouble();
    
                        long phanNguyen = (long) F;
    
                        double phanThuc = F - phanNguyen;
    
                        System.out.println(phanNguyen);
                        System.out.printf("%.2f\n", phanThuc);
                    }
                }
    

    • 1
      Luonnnn  commented on Aug. 17, 2024, 5:15 p.m.

      Để cho đỡ dài thì :

      import java.util.Scanner;

      public class test2{

      public static void main(String[] args) {
          Scanner sc = new Scanner(System.in);
          float x = sc.nextFloat();
          System.out.println((int)x);
          System.out.printf("%.2f\n",x-(int)x);
      }
      

      }