11 条题解

  • 3
    @ 2023-4-10 17:45:53
    #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;
        }
        }
        cout<<"-1";
    }
    
    
    
    
    
    • 2
      @ 2023-4-10 17:42:33
      #include<iostream>
      using namespace std;
      int n,a[99999999],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;
          }
          }
          cout<<"-1";
      }
      
      
      • 1
        @ 2024-9-28 21:36:27

        #include<bits/stdc++.h> using namespace std; int a,b,c[10005],n; int main() {

        cin>>a;
        for(int i=1;i<=a;i++)
        {
        	cin>>c[i];
        
        }
        cin>>b;
        	for(int i=1;i<=a;i++)
        {
        	if(c[i]==b)
        	{
        		n=i;
        		cout<<i;
        		break;
        	} 
        }
        if(n==0)
        cout<<"-1";
        return 0;
        

        }

        • 1
          @ 2024-5-26 10:18:27
          #include <bits/stdc++.h>
          using namespace std;
          int a,b,c[10001];
          int main(){
          	cin >> a;
          	for(int i = 1 ; i <= a ; i++) cin >> c[i];
          	cin >> b;
          	for(int i = 1 ; i <= a ; i++){
          		if(c[i] == b){
          			cout << i << endl;
          			return 0;
          		}
          	}
          	cout << -1 << endl;
          	return 0;
          }
          
          • 0
            @ 2023-5-2 16:32:20
            #include<cstdio>
            #include<string>
            #include<bits/stdc++.h>
            #define LL long long
            using namespace std;
            const int INF=0x3f3f3f3f;
            const int N=2e5+10;
            int a[2000],b,c,sum=0;
            int main(){
            	cin>>b;
            	for(int i=1;i<=b;i++){
            		cin>>a[i];
            	}
            	cin>>c;
            	for(int i=1;i<=b;i++){
            		if(a[i]==c){
            			cout<<i;
            			sum++;
            			return 0;
            		}
            	}
            	if(sum==0){
            		cout<<"-1";
            	}
            }
            
            • 0
              @ 2022-10-26 19:56:40
              #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
                @ 2024-10-21 21:10:30

                #include<iostream> #include<cstdio> 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; }

                • -1
                  #include <iostream>
                  #include <bits/stdc++.h>
                  using namespace std;
                  const int N=1e5+10;
                  const int INF=0x3f3f3f3f;
                  int n,m,a[N]; 
                  int main()
                  {
                  	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;
                  }
                  
                  
                  • -1
                    @ 2022-1-23 20:27:52
                    #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
                      @ 2023-8-10 21:44:18

                      #include<iostream> using namespace std; int n,a[1000005],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; } } cout<<"-1"; } //反抄袭水印

                      • -2
                        @ 2023-4-4 20:14:43

                        #include<bits/stdc++.h> using namespace std; int main() { int n,a[10001],m; 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; }

                        • 1

                        信息

                        ID
                        996
                        时间
                        1000ms
                        内存
                        128MiB
                        难度
                        4
                        标签
                        递交数
                        579
                        已通过
                        261
                        上传者