69 条题解

  • -1
    @ 2023-1-5 19:26:44
    #include <bits/stdc++.h> 
    using namespace std;
    int main()
    {
        int n;
        cin >> n;
        int x[n];
        for (int i = 1;i <= n;i ++)
        {
            cin >> x[i];
        }
        for (int i = 1;i <= n;i ++)
        {
            x[i] += 1;
        }
        x[n] = 1;
        for (int i = 1;i <= n;i ++)
        {
            cout << x[i] << " ";
        }
        
        return 0;
    }
    
    
    • -1
      @ 2022-12-18 20:46:41

      #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; } 4

      • -1
        @ 2022-12-18 20:46:32

        #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; }

        • -1
          @ 2022-12-18 20:46:22

          #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; }

          • -1
            @ 2022-11-3 13:21:02
            #include <iostream>
            using namespace std;
            int main()
            {
                int n,a[10],x,c;
                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)
                    {
                        c=a[i];
                        continue;
                    }
                    else
                    {
                        cout << a[i] << " ";
                        if(i==n-1)
                        {
                            cout << c;
                        }
                    }
                }
            }
            
            • -1
              @ 2022-10-12 20:49:10
              #include <>
              
              • -1
                @ 2022-10-12 20:48:19
                #include <iostream>
                
                • -1
                  @ 2022-10-7 15:49:51

                  这道题很简单

                  #include<iostream>
                  using namespace std;
                  int main()
                  {
                      int n , a[100] , b;//定义变量
                      cin >> n;
                      for (int i = 1;i <= n;i++)
                      {
                          cin >> a[i];
                      }
                      cin >> b;//不要忘了这里
                      for (int i = 1;i <= n;i++)
                      {
                          if (a[i] != b)
                          {
                              cout << a[i] << " ";//这个空格记得打出来
                          }
                      }
                      cout << b;
                      return 0;
                  }
                  

                  ok,这样就完成了

                  • -1
                    @ 2022-9-16 22:41:54

                    这道题一如既往的简单。
                    老规矩,定义数组并输入。

                    int n; 
                    cin >> n;
                    int a[n + 1];                           \\注意要定义成n+1,a[0]一会有大用处。
                    for (int i = 1; i <= n; i++)cin >> a[i];
                    

                    a[0]即可存储为a[1]也就是替换到末尾的那个数;

                    然后每一个元素都向前移动一位。

                    for (int i = 1; i <= n; i++)
                    {
                        a[i] = a[i + 1];
                    
                    } 
                    

                    然后把a[0]换到末尾(a[n])上。

                    废话不多说,上代码!

                    #include<bits/stdc++.h>
                    using namespace std;
                    int main()
                    {
                        int n; 
                        cin >> n;
                        int a[n + 1]; 
                        for (int i = 1; i <= n; i++)cin >> a[i];
                        a[0] = a[1];
                        for (int i = 1; i <= n; i++)
                        {
                            a[i] = a[i + 1];
                    
                        } 
                        a[n] = a[0];
                        for (int i = 1; i <= n; i++) cout << a[i] << ' ';
                    	re turn 0; 
                    }
                    

                    小盆友们,您学会了吗?

                    复制? 代码不易,先点赞,再复制吧! (不要忘了删倒数第二行的空格!)

                    • -1
                      @ 2022-9-11 20:37:12

                      #include <iostream> using namespace std; int main() { int x,n; cin>>n; int a[n]; for (int i=0;i<n;i++) { cin>>a[i]; } cin>>x; int b; b=a[x-1]; for (int i=x-1;i<n-1;i++) { a[i]=a[i+1]; } a[n-1]=b; for(int i=0;i<n;i++) { cout<<a[i]<<" "; } return 0; }

                      • -1
                        @ 2022-9-11 20:37:05

                        #include <iostream> using namespace std; int main() { int x,n; cin>>n; int a[n]; for (int i=0;i<n;i++) { cin>>a[i]; } cin>>x; int b; b=a[x-1]; for (int i=x-1;i<n-1;i++) { a[i]=a[i+1]; } a[n-1]=b; for(int i=0;i<n;i++) { cout<<a[i]<<" "; } return 0; }

                        • -1
                          @ 2022-9-11 20:36:57

                          #include <iostream> using namespace std; int main() { int x,n; cin>>n; int a[n]; for (int i=0;i<n;i++) { cin>>a[i]; } cin>>x; int b; b=a[x-1]; for (int i=x-1;i<n-1;i++) { a[i]=a[i+1]; } a[n-1]=b; for(int i=0;i<n;i++) { cout<<a[i]<<" "; } return 0; }

                          • -1
                            @ 2022-9-11 20:35:21

                            #include <iostream> using namespace std; int main() { int x,n; cin>>n; int a[n]; for (int i=0;i<n;i++) { cin>>a[i]; } cin>>x; int b; b=a[x-1]; for (int i=x-1;i<n-1;i++) { a[i]=a[i+1]; } a[n-1]=b; for(int i=0;i<n;i++) { cout<<a[i]<<" "; } return 0; }

                            • -1
                              @ 2022-9-6 12:57:04

                              看了一圈下来,我感觉我的还行

                              #include <bits/stdc++.h>
                              using namespace std;
                              int main()
                              {
                              int n,x,a[10],h;
                              cin >> n;
                              for (int i = 0;i < n;i++)
                              {
                              cin >> a[i];
                              }
                              cin >> x;
                              x--;
                              h=a[x];
                              for (int i = 0;i < n - 1;i++)
                              {
                              if (i < x)
                              {
                              cout << a[i] << ' ';
                              }
                              else
                              {
                              cout << a[i + 1] << ' ';
                              }
                              }
                              cout << h;
                              return 0;
                              }
                              
                              </span>
                              • -1
                                @ 2022-9-4 18:43:16
                                #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] << " ";
                                    }
                                    for (int i = 1; i <= x; i++)
                                    {
                                        cout << a[i] << " ";
                                    }
                                    return 0;
                                }
                                
                                • -1
                                  @ 2022-8-31 14:10:38

                                  #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; }

                                  • -1
                                    @ 2022-8-29 19:01:22
                                    #include<iostream>
                                    using namespace std;
                                    int main()
                                    {
                                        int a;
                                        cin >> a;
                                        int s[a];
                                        int d;
                                        int f;
                                        for (int i = 0;i < a;i++)
                                        {
                                            cin >>s[i];
                                        }
                                        cin >> d;
                                        for (int i = 0;i < a;i++)
                                        {
                                            if (i+1 == d)
                                            {
                                                f = i;
                                                break;
                                            }
                                        }
                                        for (int i = 0;i < a;i++)
                                        {
                                            if (i != f)
                                            {
                                                cout << s[i] << " ";
                                            }
                                        }
                                        cout << s[f];
                                    }
                                    
                                    • -1
                                      @ 2022-8-28 14:51:53

                                      #include <iostream> using namespace std; int main() { int a[10],n,x; cin >> n; for (int i = 0;i < n;i++) { cin >> a[i]; } cin >> x; for (int i=0;i<x;i++) { if ( a[i]==a[x-1]) { continue; }

                                      cout << a[i];
                                             
                                      }
                                      cout << a[x-1];    
                                      return 0;
                                      

                                      }

                                      • -1
                                        @ 2022-8-28 11:22:52
                                        #include<iostream>
                                        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;
                                        }
                                        
                                        • -1
                                          @ 2022-8-24 20:46:19

                                          这道题很水啊,就差说“请用queue解”了。

                                          #include <bits/stdc++.h>
                                          using namespace std;
                                          int n,x,k;
                                          queue<int> a;//搞个队列。
                                          int main()
                                          {
                                          	cin >> n;
                                          	for(int i=1;i<=n;i++)
                                          	{
                                          		cin >> k;
                                          		a.push(k);//肯定要往里头塞值啊。
                                          	}
                                          	cin >> x;
                                          	for(int i=1;i<=n;i++)
                                          	{
                                          		a.push(a.front());//把第一个元素移到后面。
                                          		a.pop();//再送它上路。
                                          		if(i==n) cout << x;//到最后一个时请出x。
                                          		if(a.front()==x) continue;//跑到x时先跳过。
                                          		k=a.front();
                                          		cout << k << " ";
                                          	}
                                          	return 0;
                                          }//所以它就长这样......
                                          

                                          信息

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