首页 › 题库 › C/C++编程考级 › C/C++编程二级 › 简答题
简答题 偏难
#12954

查找特定值

查找特定值

image1.png

image2.png

未登录也能判分,登录后才会记录
答案与解析
正确答案:<pre class="brush:cpp;toolbar:false">#include &lt;iostream&gt; using namespace std; int main() {     int n;     cin &gt;&gt; n;     int arr[10005];     for (int i = 1; i &lt;= n; ++i)     {         cin &gt;&gt; arr[i];     }     int t;     cin &gt;&gt; t;     int res = -1;     for (int i = 1; i &lt;= n; ++i)     {         if (arr[i] == t)         {             res = i;             break;         }     }     cout &lt;&lt; res;     return 0; }</pre>
这道题暂未补解析。