7 solutions

  • 5
    @ 2023-9-17 11:05:06
    #include<bits/stdc++.h>
    using namespace std;
    double x,y;
    int main(){
    	cin>>x;
    	if(x>=0&&x<5) y=2.5-x;
    	if(x>=5&&x<10) y=2-1.5*(x-3)*(x-3);
    	if(x>=10&&x<20) y=x/2-1.5;
    	cout<<fixed<<setprecision(3)<<y<<endl;
    }
    
    • 2
      @ 2024-1-27 11:42:20
      #include <iostream>
      #include <algorithm>
      #include <iomanip>
      using namespace std;
      
      int main()
      {
      	double x, y = 0;
      	cin >> x;
      	if(x < 5 && x >= 0) y = 2.5 - x;
      	else if(x < 10 && x >= 5) y = 2 - 1.5 * (x - 3) * (x - 3);
      	else y = x / 2 - 1.5;
      	cout << fixed << setprecision(3) << y << endl;
      	return 0;
      }
      
      • 2
        @ 2023-10-4 15:08:34
        #include<cstdio>
        using namespace std;
        int main()
        {
            double x,y;
            scanf("%lf",&x);
            if (0<=x&&x<5) y=-x+2.5;
              else if (5<=x&&x<10) y=2-1.5*(x-3)*(x-3);
              else if (10<=x&&x<20) y=x/2.0-1.5;
            printf("%.3lf",y);
            return 0;
        }
        
        • 1
          @ 2024-7-10 16:51:50

          #include<bits/stdc++.h> using namespace std; int main(){ double x; cin>>x; if(0<=x&&x<5){ cout<<fixed<<setprecision(3)<<-x+2.5;

          }
          
          else  if(5<=x&&x<10){
          	cout<<fixed<<setprecision(3)<<2-1.5*(x-3)*(x-3);}
          
          
          else if	
          (10<=x&&x<20){
          	cout<<fixed<<setprecision(3)<<x/2-1.5;}
          
          return 0;
          

          }

          😄 看看我的最基础题解

          • 1
            @ 2024-1-27 11:41:50
            #include <iostream>
            #include <algorithm>
            #include <iomanip>
            using namespace std;
            
            int main()
            {
            	double x, y = 0;
            	cin >> x;
            	if(x < 5 && x >= 0) y = 2.5 - x;
            	else if(x < 10 && x >= 5) y = 2 - 1.5 * (x - 3) * (x - 3);
            	else y = x / 2 - 1.5;
            	cout << fixed << setprecision(3) << y << endl;
            	return 0;
            }
            
            • 1
              @ 2023-9-19 19:01:06
              #include 
              using namespace std;
              void f(float x);
              int main(int argc, char **argv){
              float x;
              cin >> x;
              f(x);
              return 0;
              }
              void f(float x){
              double y;
              if (x < 5){
              y = -x + 2.5;
              printf("%.3f",y);
              }else if(x < 10){
              y = 2 - 1.5 * (x - 3) * (x - 3);
              printf("%.3f",y);
              }else if(x < 20){
              y = (x / 2) - 1.5;
              printf("%.3f",y);
              }
              }
              
              • 0
                @ 2024-1-27 9:14:19
                #include<iostream>
                #include<iomanip>
                using namespace std;
                long double x,y;
                int main(){
                	cin>>x>>y;
                	if(x>=0&&x<5) y=-x+2.5;
                	else if(x>=5&&x<10) y=2-1.5*(x-3)*(x-3);
                	else if(x>=10&&x<20) y=x/2-1.5;
                	cout<<fixed<<setprecision(3)<<y;
                	return 0;
                }
                
                • 1

                Information

                ID
                538
                Time
                1000ms
                Memory
                256MiB
                Difficulty
                3
                Tags
                # Submissions
                226
                Accepted
                114
                Uploaded By