Array-04. Find Integer (10) time limit MS Memory limit 65536 KB code length limit 8000 B award Program StandardAuthor Yang Xifan (City College of Zhejiang University)
The subject asks for a given x from the input n integers. If found, the position of the output x (starting from 0), if not found, outputs "not Found".
Input format:
The input gives 2 positive integers n (<=20) and x in line 1th, and the 2nd line gives n integers. Numbers do not exceed long integers, separated by spaces.
Output format:
Prints the position of x in a row, or "not Found".
Input Sample 1:
5 73 5 7 1 9
Output Example 1:
2
Input Sample 2:
5 73 5 8 1 9
Output Example 2:
Not Found
1#include <stdio.h>2#include <math.h>3#include <stdlib.h>4#include <string.h>5 intMain ()6 {7 intn, I, flag =0;8 Long LongX, a[ -];9scanf"%d%lld", &n, &x);Ten for(i =0; I < n; i++) Onescanf"%lld", &a[i]); A for(i =0; I < n; i++) - { - if(A[i] = =x) the { -Flag =1; - Break; - } + } - if(!flag) +printf"Not found\n"); A Else atprintf"%d\n", i); - return 0; -}
Array-04. Find integer