15 条题解

  • 2
    @ 2022-5-21 20:54:32

    主要还是保留一位小数的知识点和基础运算,上代码!

    #include <bits/stdc++.h>//用万能头是一个好习惯
    using namespace std;
    int main()
    {
        int n,a,b;
        double f;
        cin >> n;
        a=n+8;
        b=a-2;
        cout << n << endl;
        cout << a << endl;//注意换行
        cout << b << endl;
        f=(a+b+n)/3.0;
        printf("%.1f",f);//保留一位小数
        return 0;
    }
    

    日常第十八题,嗨害嗨~~~

    • @ 2022-7-11 15:12:05

      用万能头是个好习惯?我从来都是杜绝万能头!

    • @ 2022-7-20 21:05:20

      我都不想打万能头

  • 0
    @ 2023-10-6 16:58:15
    #include <iostream>
    #include <iomanip>
    using namespace std;
    int main()
    {
        double x, y, z;
        cin >> x;
        y = x + 8;
        z = y - 2;
        cout << x << endl << y << endl << z << endl << fixed << setprecision(1) << (x + y + z) / 3.0;
        return 0;
    }
    
    • 0
      @ 2023-8-24 11:15:40

      过辣!(脑残人士的欢呼)

          long long a,b,c;
          cin>>a;
          cout<<a<<endl;
          b=a+8;
          cout<<b<<endl;
          c=b-2;
          cout<<c<<endl;
          cout<<fixed<<setprecision(1)<<1.0*(a+b+c)/3;
      
      • 0
        @ 2022-9-1 16:58:37
        printf("%d\n%d\n%d\n%.1f",n,n+8,n+6,(1.0*n*3+14)/3);
        
        • 0
          @ 2022-7-16 14:36:41
          #include <bits/stdc++.h>
          using namespace std;
          int main()
          {
              double a,b,c,sum=0,abs;
              cin >>a;
              b=a+8;
              c=b-2;
              sum=a+b+c;
              abs=sum/3;
              cout <<a <<endl;
              cout <<b <<endl;
              cout <<c <<endl;
              cout <<fixed <<setprecision(1) <<abs;
              return 0;
          }真不错
          
          • 0
            @ 2022-5-26 14:14:29

            题解:还是注意输出平均数的保留一位。

            printf("%.1f",avg);
            

            或者

            cout<<fixed<<setprecision(1)<<avg;
            
            • 0
              @ 2022-5-24 19:11:43
              啊啊啊啊啊就是记不住保留一位小数的代码只能Ctrl+C了
              其实还是和我的第一个题解一样
              不用过多地设置变量,但是如果设少的话会麻烦一些
              
              我认为有甲乙丙三个变量就够了
              惜行如金的我把输出甲乙丙三个人的钱的那三行代码搞到一行去了
              废话不多说上代码!!!!!
                  int n, a, b;
                  cin >> n;
                  a = n + 8;
                  b = a - 2;
                  cout << n << endl << a << endl << b << endl;
                  cout << fixed << setprecision(1) << (n + a + b)/3.0;
                  return 0;
              总的来说这道题不是很难,重点在于平均数的计算
              第二个题解,鸡汤来喽
              • -1
                @ 2023-9-8 21:10:17
                #include<bits/stdc++.h>
                using namespace std;
                int main()
                {
                    double a , b , c , v;
                    cin >> a;
                    b = a + 8;
                    c = b - 2;
                    v = (a+b+c)/3;
                    cout << a << endl << b << endl << c <<endl;
                    printf("%.1f",v);
                    return 0;
                }
                
                • -1
                  @ 2023-9-1 8:03:20

                  挺简单的❤️

                  #include <bits/stdc++.h>
                  using namespace std;
                  int main(){
                      int n,y,b;
                      double p;
                      cin >> n;
                      y = n + 8;
                      b = y - 2;
                      p = (n + y + b) / 3.0;
                      cout << n << endl << y << endl << b << endl;
                      cout << fixed << setprecision(1) << p;
                      return 0;
                  }
                  
                  • -1

                    主要还是保留一位小数的知识点,这道题只需1个变量n代表甲,其他的都能用n算出。

                    #include <bits/stdc++.h> 
                    using namespace std;
                    int main()
                    {
                    	int n,a = 0,b = 0;
                    	double num = 0;
                    	cin >> n;
                    	a = n + 8;
                    	b = a - 2;
                    	num = (n + a + b) / 3.0;
                    	cout << n << endl << a << endl << b << endl;
                    	cout << fixed << setprecision(1) << num;
                    	return 0;
                    }
                    
                    • -1
                      @ 2022-7-5 20:40:20

                      运用保留小数的方法

                      #include <bits/stdc++.h>
                      using namespace std;
                      int main()
                      {
                          int n, a, b;
                          cin >> n;
                          a = n + 8;
                          b = a - 2;
                          cout << n << endl << a << endl << b << endl;
                          cout << fixed << setprecision(1) << (n + a + b)/3.0;
                          return 0;
                      }
                      

                      不算太难,还好。

                      • -1
                        @ 2022-7-3 20:11:13

                        #include <bits/stdc++.h> using namespace std; int main() { int n; cin>>n; cout<<n<<endl; cout<<n+8<<endl; cout<<n+6<<endl; cout<<fixed<<setprecision(1)<<(3*n+14)/3.0;//先求平均数再变1位小数! return 0; } 这道题只需1个变量n代表甲,其他的都能用n算出;

                        • -1
                          @ 2022-6-7 13:31:30

                          #include <bits/stdc++.h> using namespace std; int main() { int n,a=0,b=0; cin>>n; a=n+8; b=a-2; cout<<n<<endl<<a<<endl<<b<<endl; cout<<fixed<<setprecision(1)<<(n+a+b)/3.0; return 0; }

                          • -1
                            @ 2022-6-4 21:12:35

                            #include <bits/stdc++.h>//奥力给 using namespace std; int main() { int n,a,b; double f; cin >> n; a=n+8; b=a-2; cout << n << endl; cout << a << endl;//注意换行 cout << b << endl; f=(a+b+n)/3.0; printf("%.1f",f);//保留一位小数 return 0; }

                            • -2
                              @ 2022-7-14 18:39:26
                              #include <bits/stdc++.h>//用万能头是一个好习惯
                              using namespace std;
                              int main()
                              {
                                  int n,a,b;
                                  double f;
                                  cin >> n;
                                  a=n+8;
                                  b=a-2;
                                  cout << n << endl;
                                  cout << a << endl;//注意换行
                                  cout << b << endl;
                                  f=(a+b+n)/3.0;
                                  printf("%.1f",f);//保留一位小数
                                  return 0;
                              }
                              
                              • 1

                              信息

                              ID
                              609
                              时间
                              1000ms
                              内存
                              64MiB
                              难度
                              5
                              标签
                              递交数
                              871
                              已通过
                              325
                              上传者