You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
676 B

#include<bits/stdc++.h>
using namespace std;
#define MAX 101
void input(int num[]) {
int i;
srand((unsigned)time(NULL));
for(i=1; i<MAX; i++)
num[i]=rand()%100;
}
void output(int num[]) {
int i;
for(i=1; i<MAX; i++) {
printf("%5d", num[i]);
if(0==i%10)
printf("\n");
}
}
int find(int num[], int x) {
int i;
for(i=1; i<MAX; i++)
if(x == num[i])
return i;
return 0;
}
int main() {
int x, pos, num[MAX];
input(num);
printf("num...: \n");
output(num);
printf("Enter find num: ");
scanf("%d", &x);
pos=find(num, x);
if(pos)
printf("OK! %d is found in pos: %d\n", x, pos);
else
printf("Sorry! %d is not found... in num\n", x);
return 0;
}