69 条题解

  • 0
    @ 2023-11-19 14:02:01

    点赞一下

    #include<iostream>
    using namespace std;
    long long n,a[99999999]; 
    int main(){
    	cin>>n;
    	for(int i=1;i<=n;i++){
    		cin>>a[i];
    	}
    	int m;
    	cin>>m;
    	for(int i=1;i<=m;i++){
    		int x=a[1];
    		for(int j=1;j<=n;j++){	
    			a[j]=a[j+1];
    		}
    		a[n]=x;
    	}
    	for(int i=1;i<=n;i++){
    		cout<<a[i]<<' ';
    	}
    	return 0;
    } 
    
    • 0
      @ 2023-11-19 14:01:01
      #include<iostream>
      using namespace std;
      long long n,a[99999999];
      int main(){
      cin>>n;
      for(int i=1;i<=n;i++){
      cin>>a[i];
      }
      int m;
      cin>>m;
      for(int i=1;i<=m;i++){
      int x=a[1];
      for(int j=1;j<=n;j++){	
      a[j]=a[j+1];
      }
      a[n]=x;
      }
      for(int i=1;i<=n;i++){
      cout<<a[i]<<' ';
      }
      return 0;
      }
      
      • 0
        @ 2023-11-18 10:01:55
        #include <iostream>
        using namespace std;
        int main()
        {
            int a[100], n, x, y;
            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] << " ";
        		}
                else
                {
        		    y = a[i];
        		}
        	}
            cout << y << endl;
            return 0;
        }
        
        • 0
          @ 2023-8-13 12:14:53
          #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;
          }
          
        • 0
          @ 2023-8-9 17:15:44
          #include<iostream>
          using namespace std;
          int main()
          {
              int n, a[10], x, y;
              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))
                  {
                      y = a[i];
                  }
              }
              for (int i = 0;i < n;i++)
              {
                  if (a[i] != y)
                  {
                      cout << a[i] << " ";
                  }
              }
              cout << y;
              return 0;
          }
          
          • 0
            @ 2023-8-7 9:50:48
            #include <iostream>
            using namespace std;
            int main()
            {
                int a[100], n, x, y;
                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] << " ";
            		}
                    else
                    {
            		    y = a[i];
            		}
            	}
                cout << y << endl;
                return 0;
            }
            
            • 0
              @ 2023-7-6 18:11:41

              有点小绕 #include <iostream> using namespace std; int main() { int n,x,a[10]; cin >> n; for(int i = 0;i < n;i++) { cin >> a[i]; } cin >> x; for(int i = 0;i < n;i++) { if(a[i] == x) { for(int c = i+1;c < n;c++) { a[i] = a [c]; i++; } a[i] = x; } break; } for(int i = 0;i < n;i++) { cout << a[i] << " "; } return 0; }//已AC

              • 0
                @ 2023-6-30 11:52:08
                #include<bits/stdc++.h>
                using namespace std;
                int n,m[20],x;
                int main(){
                	//读入 
                	cin>>n;
                	for(int i=1;i<=n;i++) cin>>m[i];
                	cin>>x;
                	//只要不是第x位就输出 
                	for(int i=1;i<=n;i++) if(m[i]!=x) cout<<m[i]<<" ";
                	//最后再输出m[x] 
                	cout<<m[x];
                	return 0;
                }
                
                
              • 0
                @ 2023-6-7 22:02:58

                这道题还好,直接上题解

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

                WA代码,放心使用吧 已AC,放心食用

                • 0
                  @ 2023-5-28 8:09:18
                  #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
                    @ 2023-8-23 15:58:39
                    #include <iostream>
                    #include <list> // 导入list
                    
                    using namespace std;
                    
                    int main()
                    {
                        list<int> lst = list<int>();
                        int n;
                        cin >> n;
                        for (int i = 0; i < n; ++i)
                        {
                            int item;
                            cin >> item;
                            lst.push_back(item);
                        }
                    
                        int data = lst.front();
                        lst.pop_front();
                        lst.push_back(data);
                    
                        for (int i : lst)
                            cout << i << ' ';
                    
                        return 0;
                    }
                    

                    (为嘛往要用链表编数组的题???)

                    • -1
                      @ 2023-8-7 12:19:49

                      仍旧是函数 给个思路,可以先输出x,再输出a【1~i】

                      #include <bits/stdc++.h>
                      using namespace std;
                      void a()
                      {
                          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;
                      }
                      int main(){
                          a();
                      }
                      
                      • -1
                        @ 2023-8-2 20:00:51
                        #include<iostream>
                        using namespace std;
                        int main()
                        {
                            int n , a[10] , x , m;//d:第x个位置上的数
                            cin >> n;
                            for (int i = 0;i < n;i++)
                            {
                                cin >> a[i]; 
                            }
                            cin >> x;
                            x -= 1;//这个数的索引等于位置-1
                            m = a[x];
                            for (int i = 0;i < n;i++)
                            {
                                if (a[i] != m)
                                {
                                    cout << a[i] << " ";
                                }
                            }//把不等于m的数输出
                            cout << m; //输出m
                            return 0;   
                        }
                        
                        • -1
                          @ 2023-7-9 17:02:00

                          教你们一招瞒天过海

                          #include <bits/stdc++.h> 
                          using namespace std;
                          int main()
                          {   int n,x;cin>>n;int a[n];
                              for (int i=0;i<n;i++){cin>>a[i];}cin>>x;//首先输入原数组
                              for (int i=1;i<x;i++){cout<<a[i]<<" ";}//输出x之前的数
                              for (int i=x;i<n;i++){cout<<a[i]<<" ";}//然后输出x之后的数
                              cout<<a[x-1];//最后输出第x个数
                              return 0;
                          }
                          

                          (压缩代码了属于是)

                          也可以在遍历中写一个条件,第x个数的时候continue,最后输出,不予展示,留给读者自行思考。

                          • -1
                            @ 2023-7-2 16:51:31

                            #include <iostream> #include <bits/stdc++.h> using namespace std; int main(){ int a,b[30],x,k; cin>>a; for (int i = 0;i < a;i++){ cin>>b[i]; } cin>>x; for (int i = 0; i < a; i++){ if (i + 1 != x) { cout << b[i] << " "; } else { k= b[i]; } } cout << k << endl; } 已AC,放心食用

                            • -1
                              @ 2023-5-12 21:14:58

                              #include <iostream> using namespace std; int main(){ int n,x,m = 0; cin >>n; int a[n]; for (int i = 0;i<n;i++){ cin >>a[i]; } cin >>x; m = a[0]; for(int i = 1;i<n;i++){ cout << a[i]<<" "; } cout <<m; return 0; } 分享一下我的卡bug方法亲测能过

                            • -1
                              @ 2023-5-2 12:02:27

                              我咋感觉不太对呢?感觉题没读懂,糊里糊涂就过了

                                  int a[15],b[15],n,x;cin>>n;
                                  for(int i=0;i<n;i++){cin>>a[i];}cin>>x;int k=x,p=n-x;
                                  for(int j=0;j<n-x;j++){b[j]=a[k];k++;}
                                  for(int o=0;o<x;o++){b[p]=a[o];p++;}
                                  for(int i=0;i<n;i++){cout<<b[i]<<" ";}return 0;
                              
                              • -1
                                @ 2023-4-23 22:34:33
                                #include<iostream>
                                using namespace std;
                                int main()
                                {
                                    int n,a[100],x;
                                    cin>>n;
                                    for(int i=0;i<n;i++){
                                        cin>>a[i];
                                    }
                                    cin>>x; 
                                    for(int i=0;i<n;i++){
                                        if(a[i]==x){
                                            continue;
                                        }
                                        cout<<a[i]<<" ";
                                    }
                                    cout<<a[x-1];
                                    return 0;
                                
                                • -1
                                  @ 2023-3-28 22:04:00
                                  #include<bits/stdc++.h>
                                  using namespace std;
                                  int n,x,a[17];
                                  int main()
                                  {
                                      cin>>n;
                                      for (int i=1;i<=n;i++)
                                          cin>>a[i];
                                      cin>>x;
                                      for (int i=1;i<=n;i++)
                                      {
                                          if (i==x)
                                              continue;
                                          cout<<a[i]<<" ";
                                      }
                                      cout<<x;
                                      return 0;
                                  }
                                  
                                  • -1
                                    @ 2023-3-22 13:22:44

                                    基础版

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

                                    叛逆版

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

                                    信息

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