6 条题解

  • 5
    @ 2024-1-21 14:24:33

    都怪这个小星上课不好好听讲,让我们来做这道题,还好这题不难,我一个刚学到Level4的都会~只要先判断这个数列是等差数列还是等比数列,再根据情况求出后三个数,最后打印出来就行了O(∩_∩)O

    已AC,请放心食用

    #include <iostream>
    using namespace std;
    int main()
    {
        double a, b, c, d, e, f;
        cin >> a >> b >> c;
        if (b / a == c / b)
        {
            d = c * (c / b);
            e = d * (c / b);
            f = e * (c / b);
        }
        else if (b - a == c - b)
        {
            d = c + (c - b);
            e = d + (c - b);
            f = e + (c - b);
        }
        cout << d << " " << e << " " << f;
        return 0;
    }
    

    养成好习惯,看后点个赞( •̀ ω •́ )✧

    • 1
      @ 2023-7-7 13:00:33
      #include <iostream>
      using namespace std;
      int main()
      {
      	double a, b, c;//设置为double是为了方便除法,如果是int的话除出来都是整数
      	cin >> a >> b >> c;
      	int num;
      	if (c - b == b - a && c / b != b / a)//等差数列
      	{
      		num = c - b;
      		cout << c + num << " " << c + 2 * num << " " << c + 3 * num;
      	}
      	if (c - b != b - a && c / b == b / a)//等比数列
      	{
      		num = c / b;
      		cout << c * num << " " << c * num * num << " " << c * num * num * num;
      	}
      	if (a == b && b == c)//常数列,既是等差数列又是等比数列
      	{
      		cout << a << " " << a << " " << a;
      	}
      	return 0;
      }
      
      • @ 2024-1-21 14:26:05

        你其实不用判断常数列的情况,题目不是说了吗:现在小星已经知道这串序列要么是等比数列,要么是等差数列。

    • 0
      @ 2023-10-12 12:20:10
      #include<bits/stdc++.h>
      using namespace std;
      int a[10];
      int main()
      {
          for(int i=1;i<=3;i++)
          {
              cin>>a[i];
          }
          if(a[2]-a[1]==a[3]-a[2])
          {
              for(int i=1;i<=3;i++)
              {
                  a[3]+=a[2]-a[1];
                  cout<<a[3]<<" ";
              }
          }
          else
          {
              
              for(int i=1;i<=3;i++)
              {
                  a[3]*=a[2]/a[1];
                  cout<<a[3]<<" ";
              }
          }
          return 0;
      }
      
      • -1
        @ 2023-4-22 14:21:17
        #include <bits/stdc++.h> 
        using namespace std;
        int main()
        {
            int a, b, c;
            cin >> a >> b >> c;
            if (b - a == c - b)
            {
                int d = c + (b - a);
                for (int i = 1; i <= 3; i++)
                {
                    cout << d << " ";
                    d += b - a;
                }
            }
            if (b / a == c / b)
            {
                int d = c * (b / a);
                for (int i = 1; i <= 3; i++)
                {
                    cout << d << " ";
                    d *= b / a;
                }
            }
            return 0;
        }
        
        • -1
          @ 2023-4-2 19:13:47

          因为只用输出后三个数可以直接算

          #include<bits/stdc++.h>
          using namespace std;
          int main()
          {
              int a,b,c;
              cin>>a>>b>>c;
              if (b-a==c-b)
                  cout<<c+(b-a)<<" "<<c+2*(b-a)<<" "<<c+3*(b-a);
              else
                  cout<<c*(b/a)<<" "<<c*(b/a)*(b/a)<<" "<<c*(b/a)*(b/a)*(b/a);
              return 0;
          }
          
          • -1
            @ 2022-11-10 13:51:34

            号没了

            #include <iostream>
            using namespace std;
            int main()
            {
                double a1,a2,a3;
                cin >> a1 >> a2 >> a3;
                if(a2/a1==a3/a2)
                {
                    cout << a3*(a3/a2) << " " << a3*(a3/a2)*(a3/a2) << " " << a3*(a3/a2)*(a3/a2)*(a3/a2);
                }
                else
                {
                    cout << a3+(a3-a2) << " " << a3+(a3-a2)+(a3-a2) << " " << a3+(a3-a2)+(a3-a2)+(a3-a2); 
                }
            }
            
            • 1

            信息

            ID
            52
            时间
            1000ms
            内存
            16MiB
            难度
            1
            标签
            递交数
            179
            已通过
            118
            上传者