20 条题解

  • 1
    @ 2023-4-10 17:39:30
    #include<stdio.h>
    #include<iostream>
    using namespace std;
    int n,a[100000001],t;  //全局变量,定义数组下标,不能用变量
    int main()
    {
        cin>>n;
        for(int i=1;i<=n;i++){
            cin>>a[i];
        }
        cin>>t;
        for(int i=1;i<=n;i++){
            if(a[i]==t) {
            cout<<i;
            return 0;
        }
        }
    }
    
    • 1
      @ 2023-4-10 17:38:37
      #include<iostream>
      using namespace std;
      int n,a[999999],t;
      int main()
      {
          cin>>n ;
          for(int i=1 ; i <= n ;i ++){
              cin>>a[i];
          }
          cin>>t ;
          for(int i=1 ;i <= n ; i++){
              if(a[i] == t){
              cout << i;
              return 0;
          }
          }
      }
      
      • 0
        @ 2024-11-10 11:52:53
        #include<iostream>
        #include<string.h>
        using namespace std;
        int a[10005],n;
        int main(){
        	cin>>n;
        	for(int i=1;i<=n;i++){
        		cin>>a[i];
        	}
        	int x;
        	cin>>x;
        	int id=-1;
        	for(int i=1;i<=n;i++){
        		if(a[i]==x){
        			id=i;
        			break;
        		}
        	}
        	cout<<id<<endl;
        	return 0;
        }
        
        • 0
          @ 2024-10-21 20:55:14

          min

          int

          • 0
            @ 2024-10-21 20:54:21

            min

            • 0
              @ 2024-10-20 18:56:12

              #include<stdio.h> #include<iostream> using namespace std; int n,a[100000001],t; //全局变量,定义数组下标,不能用变量 int main() { cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]; } cin>>t; for(int i=1;i<=n;i++){ if(a[i]==t) { cout<<i; return 0; } } }

              • 0
                @ 2024-10-20 18:55:21
                #include<stdio.h>
                #include<iostream>
                using namespace std;
                int n,a[100000001],t;  //全局变量,定义数组下标,不能用变量
                int main()
                {
                    cin>>n;
                    for(int i=1;i<=n;i++){
                        cin>>a[i];
                    }
                    cin>>t;
                    for(int i=1;i<=n;i++){
                        if(a[i]==t) {
                        cout<<i;
                        return 0;
                    }
                    }
                }
                
                • 0
                  @ 2024-10-20 18:51:43

                  #include<iostream> #include<string.h> using namespace std; int a[10005],n; int main(){ cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]; } int x; cin>>x; int id=-1; for(int i=1;i<=n;i++){ if(a[i]==x){ id=i; break; } } cout<<id<<endl; return 0; }

                  • 0
                    @ 2024-5-17 18:58:09

                    #include<iostream> using namespace std; int main(){ int a[10005]; int n; cin>>n; for(int i=1;i<=n;i++) cin>>a[i]; int m; cin>>m; int flag=-1; for(int i=1;i<=n;i++){ if(m==a[i]){ flag=i; break; } } cout<<flag<<endl;

                    return 0;
                    

                    }

                    • 0
                      @ 2024-5-17 18:56:18

                      #include<iostream> using namespace std; int main(){ int a[10005]; int n; cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]; } int m; cin>>m; int flag= -1; for(int i=1;i<=n;i++) { if(m==a[i]) { flag=i; break; } } cout<<flag<<endl; return 0;

                      }

                      • 0
                        @ 2023-12-14 20:47:20

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

                        • 0
                          @ 2023-4-19 19:47:44

                          #include <iostream> using namespace std;

                          int n , a[10005] ,x; int main() { cin>>n; for(int i = 1;i <=n;i++) { cin >>a[i]; } cin>>x; for(int i = 1;i <=n;i++) { if(x == a[i]) { cout<<i; return 0; } }

                          return 0;
                          

                          }

                          • 0
                            @ 2023-4-19 19:45:28
                            #include <iostream>
                            using namespace std;
                            int n,a[10010],x;
                            int main()
                            {
                            	cin>>n;
                            	for(int i=1;i<=n;i++)
                            	{
                            		cin>>a[i];
                            	}
                            	cin>>x;
                            	for(int i=1;i<=n;i++)
                            	{
                            		if(x==a[i])
                            		{
                            			cout<<i;
                            		return 0;
                            		}
                            		
                            	}
                            	cout<<-1;
                            	return 0;
                             } 
                            
                            • -1
                              @ 2023-4-10 18:10:17
                              #include<stdio.h>
                              #include<iostream>
                              using namespace std;
                              int n,a[100000001],t;  
                              int main()
                              {
                                  cin>>n;
                                  for(int i=1;i<=n;i++){
                                      cin>>a[i];
                                  }
                                  cin>>t;
                                  for(int i=1;i<=n;i++){
                                      if(a[i]==t) {
                                      cout<<i;
                                      return 0;
                                  }
                                  }
                              }
                              
                              • -1
                                @ 2022-1-23 20:27:37
                                #include <iostream>
                                using namespace std;
                                int a[10001];
                                int main()
                                {
                                	int n,  x, i;
                                	cin >> n;
                                	for (i=0; i<n; i++) cin >> a[i];
                                	cin >> x;
                                	for (i=0; i<n; i++)
                                	{
                                	if (a[i] == x)
                                	{
                                	cout << i+1 << endl;
                                	return 0;
                                	}
                                	}
                                	cout << "-1" << endl;
                                	return 0;
                                	}
                                    ```
                                • -2
                                  @ 2022-8-11 17:30:07
                                  #include <bits/stdc++.h>
                                  
                                  using namespace std;
                                  
                                  int main(void)
                                  {
                                  	int n;
                                  	
                                  	cin >> n;
                                  	
                                  	int x[n];
                                  	
                                  	for (int i = 1; i <= n; i++)
                                  	{
                                  		cin >> x[i];
                                  	}
                                  	
                                  	int y;
                                  	
                                  	cin >> y;
                                  	
                                  	int m = 1;
                                  	
                                  	for (int i = 1; i <= n; i++)
                                  	{
                                  		if (x[i] != y)
                                  		{
                                  			m++;
                                  		}
                                  		
                                  		if (x[i] == y)
                                  		{
                                  			cout << m;
                                  			break;
                                  		}
                                  	}
                                  	
                                  	if (m == n + 1)
                                  	{
                                  		cout << -1;
                                  	}
                                  	
                                  	return 0;
                                  }
                                  
                                  • -4
                                    @ 2023-4-2 19:41:20

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

                                    • -4
                                      @ 2023-4-2 18:42:40

                                      #include<iostream> using namespace std; int n,x,a[10010]; int main() { 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<<i; return 0; } } cout<<-1; return 0; }

                                      • -4
                                        @ 2023-3-7 16:56:00
                                        #include <iostream>
                                        using namespace std;
                                        int main()
                                        {
                                            int n, a[10000], x, i;
                                            cin >> n;
                                            for (i=0; i<n; i++) cin >> a[i];
                                            cin >> x;
                                            for (i=0; i<n; i++){
                                                if (a[i] == x){
                                                    cout << i+1 << endl;
                                                    return 0;
                                                }
                                            }
                                            cout << "-1" << endl;
                                            return 0;
                                        }
                                        
                                        • -4
                                          @ 2022-10-26 19:55:10
                                          #include <iostream>
                                          #include <stack>
                                          #include <cmath>
                                          #include <vector>
                                          #include <string.h>
                                          #include <queue>
                                          #include <stdio.h>
                                          #include <iomanip>
                                          #include <cstdio>
                                          #include <algorithm>
                                          #define int long long
                                          using namespace std;
                                          const int N = 1e5 + 10;
                                          const int INF = 0x3f3f3f3f;
                                          int a[N];
                                          signed main()
                                          {
                                          	int n, 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 << i << endl;
                                          			return 0;
                                          		}
                                          	}
                                          	cout << "-1" << endl;
                                          	return 0;
                                          }
                                          

                                          一个-1都没有

                                          所以用这个也能过

                                          #include <iostream>
                                          #include <stack>
                                          #include <cmath>
                                          #include <vector>
                                          #include <string.h>
                                          #include <queue>
                                          #include <stdio.h>
                                          #include <iomanip>
                                          #include <cstdio>
                                          #include <algorithm>
                                          #define int long long
                                          using namespace std;
                                          const int N = 1e5 + 10;
                                          const int INF = 0x3f3f3f3f;
                                          int a[N];
                                          signed main()
                                          {
                                          	int n, 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 << i << endl;
                                          			break;
                                          		}
                                          	}
                                          	return 0;
                                          }
                                          
                                          • 1

                                          信息

                                          ID
                                          995
                                          时间
                                          1000ms
                                          内存
                                          128MiB
                                          难度
                                          6
                                          标签
                                          递交数
                                          1191
                                          已通过
                                          408
                                          上传者