4 solutions

  • 4
    @ 2023-10-29 14:31:37
    #include<iostream>
    #include<cmath>
    using namespace std;
    int main()
    {
     float n;
     cin>>n;//输入
     printf("%.2f",abs(n));//格式化输出
     return 0;//完结散花!
    }
    
    • 1
      @ 2024-1-27 11:31:15
      #include <iostream>
      #include <iomanip>
      using namespace std;
      
      int main()
      {
      	long long a;
      	cin >> a;
      	if(a >= 0) cout << a << ".00" << endl;
      	if( a < 0) cout << 0 - a << ".00" <<  endl;
      	
      	return 0;
      }
      
      • 0
        @ 2024-1-26 11:49:19
        #include<bits/stdc++.h>
        #define ll long long
        using namespace std;
        double a;
        int main(){
        	cin>>a;
        	cout<<fixed<<setprecision(2)<<abs(a)<<"\n";
        	return 0;
        }
        

        abs()绝对值函数

        • -1
          @ 2023-10-5 14:55:17
          #include<bits/stdc++.h>
          using namespace std;
          double n,m;
          int main(){
          	cin>>n;
              m = abs(n);
              cout<<fixed<<setprecision(2)<<m;
          	return 0;
          }//cmath库,但这是万能头。
          
          • 1

          Information

          ID
          527
          Time
          1000ms
          Memory
          256MiB
          Difficulty
          5
          Tags
          # Submissions
          180
          Accepted
          68
          Uploaded By