Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.41 KB | None | 0 0
  1. #include <stdio.h>
  2. #define N 10
  3.  
  4. int Szukaj(int A[N], int x){
  5.     int i=0;
  6.     do{
  7.         i++;
  8.     }
  9.     while((A[i]!=x) || (i!=N));
  10.     if(A[i]==x){
  11.         return i;
  12.     }
  13.     else{
  14.         return 0;
  15.     }
  16. }
  17.  
  18. int main(){
  19.     int x;
  20.     int A[N]={1, 3, 15, 17, 4, 5, 2, 21, 10, 7};
  21.     printf("Jakiej liczby szukasz?\n");
  22.     scanf("%i", &x);
  23.     printf("%i", Szukaj(A, x));
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement