Array-04. Search for integers (10), array-04

Source: Internet
Author: User

Array-04. Search for integers (10), array-04

This question requires that the given X be searched from the N integers entered. If it is Found, the position of output X (starting from 0); if it is Not Found, the output is "Not Found ".

Input Format:

The input returns two positive integers N (<= 20), X, and N integers in row 1st. The numbers cannot exceed the length integer and are separated by spaces.

Output Format:

Output the position of X in a row, or "Not Found ".

Input Example 1:
5 73 5 7 1 9
Output Example 1:
2
Input Example 2:
5 73 5 8 1 9
Output Example 2:
Not Found

 

 

# Include <stdio. h>
Int main (){
Int n, x, I, flag = 1;
Scanf ("% d", & n, & x );
Long int str [25];
For (I = 0; I <n; I ++ ){
Scanf ("% ld", & str [I]);
}
For (I = 0; I <n; I ++ ){
If (str [I] = x ){
Printf ("% d", I );
Flag = 0;
}
}
If (flag)
Printf ("Not Found ");
Return 0;
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.