14 条题解

  • 7
    @ 2021-12-5 19:11:08

    直接上代码,有空更新题解

    #include <iostream>
    #include <stdio.h>
    using namespace std;
    
    int main()
    {
        double x,y;
    
        cin>>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 {
        y=x/2-1.5;
        }
        printf("%.3f",y) ;
        return 0;
    }
    
    • 4
      @ 2024-11-22 20:23:51
      #include<iomanip> 
      #include<cmath> 
      using namespace std; 
      double x,y;
      int main() 
      {
      	cin>>x; 
      	if(0<=x&&x<5) 
      	{ 
      		y=x*-1+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-1.5; 
      	} 
        	cout<<fixed<<setprecision(3)<<y;
      	return 0;
      
      }
      
      • 2
        @ 2025-12-7 14:25:04
        #include <iostream>
        #include <iomanip>
        using namespace std;
        int main()
        {
        	double x,ans;
        	cin >> x;
        	if (0 <= x && x < 5)
        		ans = -(x) + 2.5;
        	else if (5 <= x && x < 10)
        		ans = 2 - 1.5 * (x - 3) * (x - 3);
        	else if (10 <= x && x < 20)
        		ans = x / 2 - 1.5;
        	cout << fixed << setprecision(3) << ans;
        	return 0;
        }
        • 1
          @ 2025-7-30 16:51:22

          虽然不是最简解,很多地方还可以优化,但凡请各位大佬不要差评,毕竟我才学c++不到10 ,仅供参考,保证能AC,就当一个乐子吧,谢谢大佬们的观看!

          #include <iostream>
          #include <iomanip>
          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-11-24 11:30:54
            #include<iomanip>
            using namespace std;
            int main()
            {
            	double w,h;
            	cin>>w;
            	if(0<=w&&w<5)
            	{
            	h=-w+2.5;
            	}
            	else if(5<=w&&w<10)
            	{
            	h=2-1.5*(w-3)*(w-3);
            	}
            	else if(10<=w&&w<20)
            	{
            	h=w/2-1.5;
            	}
            	cout<<fixed<<setprecision(3)<<h;
            }
            
            • 0
              @ 2024-12-7 18:26:49
              //冒泡排序
              #include<bits/stdc++.h>
              using namespace std;
              const int N=1e5+10;
              int main(){
              	double x,sum;cin>>x;if(x>=0&&x<=5) sum=-x+2.5;
              	else if(x>=5&&x<=10){
              		sum=2-1.5*(x-3)*(x-3);
              	}
              	else if(x>=10&&x<=20)
              		sum=x*0.5-1.5;
              	cout<<fixed<<setprecision(3)<<sum<<endl;
              	return 0;
              }
              
              • 0
                @ 2024-4-19 20:07:03
                #include <iostream>
                #include <stdio.h>
                using namespace std;
                
                int main()
                {
                    double x,y;
                
                    cin>>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 {
                    y=x/2-1.5;
                    }
                    printf("%.3f",y) ;
                    return 0;
                }
                
                • 0
                  @ 2023-9-8 11:22:04
                  #include <bits/stdc++.h>
                  using namespace std;
                  const int N=1e7+10;
                  const int INF=0x3f3f3f3f;
                  int main()
                  {
                  	double x,y;
                  	cin>>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-1.5;
                  	}
                  	cout<<fixed<<setprecision(3)<<y;
                  	return 0;
                  }
                  
                  • -1
                    @ 2022-9-27 17:37:34

                    #include #include using namespace std; int main(){ double n; cin>>n; if(0<=n&&n<5) n=-n+2.5; else if(5<=n&&n<10) n=2-1.5*(n-3)*(n-3); else n=n/2-1.5; cout<<fixed<<setprecision(3)<<n<<endl; return 0; }

                    • -1
                      @ 2022-9-27 17:36:50

                      #include #include using namespace std; int main(){ double n; cin>>n; if(0<=n&&n<5) n=-n+2.5; else if(5<=n&&n<10) n=2-1.5*(n-3)*(n-3); else n=n/2-1.5; cout<<fixed<<setprecision(3)<<n<<endl; return 0; }

                      • -1
                        @ 2022-9-27 17:36:37

                        #include #include using namespace std; int main(){ double n; cin>>n; if(0<=n&&n<5) n=-n+2.5; else if(5<=n&&n<10) n=2-1.5*(n-3)*(n-3); else n=n/2-1.5; cout<<fixed<<setprecision(3)<<n<<endl; return 0; }

                        • -1
                          @ 2022-8-12 21:32:37
                          #include<bits/stdc++.h>
                          #include <iostream>
                          #include <iomanip>
                          using namespace std;
                          int main(){
                              double n;
                              cin>>n;
                              if(0<=n&&n<5)
                                  n=-n+2.5;
                              else if(5<=n&&n<10)
                                  n=2-1.5*(n-3)*(n-3);
                              else
                                  n=n/2-1.5;
                              printf("%.3lf",n);
                              return 0;
                          }
                          
                          • -1
                            @ 2022-1-23 13:49:03
                            #include <iostream>
                            #include <iomanip>
                            using namespace std;
                            int main(){
                                double n;
                                cin>>n;
                                if(0<=n&&n<5)
                                    n=-n+2.5;
                                else if(5<=n&&n<10)
                                    n=2-1.5*(n-3)*(n-3);
                                else
                                    n=n/2-1.5;
                                cout<<fixed<<setprecision(3)<<n<<endl;
                                return 0;
                            }
                            • -7
                              @ 2022-2-9 11:16:45

                              ggf nj

                              • 1

                              信息

                              ID
                              856
                              时间
                              1000ms
                              内存
                              128MiB
                              难度
                              4
                              标签
                              递交数
                              567
                              已通过
                              269
                              上传者