1 solutions

  • 0
    @ 2025-3-3 16:28:35

    C++ :

    #include<bits/stdc++.h>
    using namespace std;
    int main(){
    	double n;
    	cin>>n;
    	cout<<fixed<<setprecision(2)<<abs(n)<<endl;
    	return 0;
    }
    
    

    Java :

    import java.util.Scanner;
    
    public class Main {
    
    	public static void main(String[] args) {
    		// TODO Auto-generated method stub
    		Scanner sc = new Scanner(System.in);
    		double a = sc.nextDouble();
    		if(a > 0){
    			System.out.println(String.format("%.2f", a));
    		}else{
    			a = -1 * a;
    			System.out.println(String.format("%.2f", a));
    		}
    	}
    
    }
    

    Python :

    a=float(input())
    b=abs(a)
    print("%.2f"%b)
    
    
    • 1

    Information

    ID
    10213
    Time
    1000ms
    Memory
    16MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By