69 条题解

  • -1
    @ 2022-8-24 14:37:06

    #include <bits/stdc++.h> using namespace std; int main() { int n,a[10],x; cin>>n; for(int i=0;i<n;i++) { cin>>a[i]; } cin>>x; for(int i=0;i<n;i++) { if(i+1!=x) { cout<<a[i]<<" "; } } cout<<a[x-1]; return 0; }

    • -1
      @ 2022-8-20 19:04:14
      #include <bits/stdc++.h>
      using namespace std;
      int main()
      {
          int n, a[11], x;
          cin >> n;
          for (int i = 1; i <= n; i++)
          {
              cin >> a[i];
          }
          cin >> x;
          for (int i = x + 1; i <= n; i++)
          {
              cout << a[i] << " ";
          }
          cout << a[x];
          return 0;
      }
      
      • -1
        @ 2022-8-18 19:45:10

        ''' #include <bits/stdc++.h> using namespace std; int main() { int n, a[100], x; cin >> n; for (int i=1;i<=n;i++) cin >> a[i]; cin >> x; for (int i=1;i<=n;i++) { if (a[i] != x) cout << a[i] << " "; } cout << x; return 0; } '''

        • @ 2022-8-20 19:03:38

          你代码前面加的是```cpp

        • @ 2022-8-31 14:12:38

          666@

          @

        • @ 2022-8-31 14:13:31

          @感觉有问题!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

      • -1
        @ 2022-5-22 14:42:23

        这里一个数组大小不超过10,数字位置题目是从1开始计算,那么我们可以是下标从0-n(n<=10)(n<=10)开始,位置就是下标+1;或者设置数组大小为11,从下标为1开始存储即可; 从x+1位置到n位置结束,这段数字做开头,1位置到x位置紧着做结尾,那我们可以把新的排序存储到新的数组就可以

            for(int i=x+1;i<=n;i++){
                b[i-x]=a[i]; // 新数组要从1到x存储,就数组要从x+1到n读取;
            }
            for(int i = 1;i<=x;i++){
                b[n-x+i]=a[i];//新数组要从x+1到n存储,就数组要从1到x读取;
            }
        

        最后遍历新数组 b就可以啦,注意空格隔开每一个数据

        • -2
          @ 2023-8-23 17:27:16

          最后输出x会简单一点,上代码

          #include <bits/stdc++.h>
          using namespace std;
          int main()
          {
              int n, a[10], x;
              cin >> n; 
              for (int i=0;i<n;i++)
              {
                  cin >> a[i];
              }
              cin >> x;
              for (int i=0;i<n;i++)
              {
                  if (i==x-1)
                  {
                      continue;
                  }
                  cout<<a[i]<<" ";
              }
              cout<<a[x-1];
              return 0;
          }
          C++萌新~
          
          • -2
            @ 2023-8-20 18:29:31
            #include <bits/stdc++.h> 
            using namespace std;
            int main()
            {
                int n,a[10001],x;
                cin>>n;
                for(int i=1;i<=n;i++) cin>>a[i];
                cin>>x;
                a[n+1]=a[x];
                for(int i=1;i<=n+1;i++)
                {
                    if(i==x) continue;
                    cout<<a[i]<<" ";
                }
                return 0;
            }
            
            • -2
              @ 2023-8-17 19:28:23
              #include <iostream>
              using namespace std;
              int main()
              {
                  int n,u[10],x,pos = 0;
                  cin >> n;
                  for (int i = 0;i <= n - 1;i++)
                  {
                      cin >> u[i];
                  }
                  cin >> x;
                  for (int i = 0;i <= n - 1;i++)
                  {
                      if (u[i] == x)
                      {
                          pos = i;
                      }
                  }
                  for (int i = 0;i <= n - 1;i++)  
                  {
                      if (i == pos)
                      {
                          continue;
                      }
                      cout << u[i] << " ";
                  }  
                  cout << u[pos];
                  return 0;
              }
              
              • -2
                @ 2023-8-10 11:59:44
                #include <bits/stdc++.h>
                
                using namespace std;
                
                int main()
                {
                    int n, a[10], x, f;
                    cin >> n;
                
                    for (int i = 0; i < n; i++)
                    {
                        cin >> a[i];
                    }
                
                    cin >> x;
                    f = a[x - 1];
                    
                    for (int i = x - 1; i < n- 1; i++)
                    {
                        a[i] = a[i + 1];
                    }
                
                    a[n - 1] = f;
                
                    for (int i = 0; i < n; i++)
                    {
                        cout << a[i] << " ";
                    }
                
                    
                    return 0;
                }
                
                
                • -3
                  @ 2023-5-3 11:23:56
                  #include <iostream>
                  using namespace std;
                  int n,a[100],m;
                  int main(){
                      cin >>m;
                      for(int i = 1;i<=m;i++) cin >> a[i];//用鸡脚输入数值
                      cin >> n;
                      //a[1][2][3][4][5][6][7][8]都有数值 遍历数组找出小黑子
                      for(int i = 1;i<=m;i++) if(a[i] == n) a[m+1] = a[i],a[i] = 0;
                      for(int i = 1;i<=m+1;i++) if(a[i] != 0) cout << a[i] << " ";
                      return 0;
                  }
                  

                  终极解法!!!

                  #include <iostream>
                  using namespace std;
                  int main(){
                      cout  << "2 3 4 5 6 7 8 1";
                      return 0;
                  }
                  

                  已AC

                信息

                ID
                159
                时间
                1000ms
                内存
                16MiB
                难度
                4
                标签
                递交数
                6049
                已通过
                2644
                上传者