Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <time.h>
- #define size 10
- getRandInt(int min, int max) {
- return rand() % (max - min + 1) + min;
- }
- void main() {
- srand(time(0));
- int tab[size] = {0};
- int min = 0, max = 10;
- for(int i = 0; i < size; i++) {
- tab[i] = getRandInt(min, max);
- printf("%d\n", tab[i]);
- }
- printf("Podaj szukana wartosc z zakresu %d do %d\n", min, max);
- int x;
- scanf("%d", &x);
- for(int i = 0; i < size; i++) {
- if(tab[i] == x) {
- printf("Podana wartosc znajduje sie na pozycji %d", i);
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment