Advertisement
ridjis

nalazi u nizu

Dec 1st, 2013
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (* niz od 5 brojeva i ispituje da li uneti broj pripada nizu*)
  2. MODULE rz2_2;
  3. FROM InOut IMPORT WriteLn, WriteString, WriteCard, ReadCard;
  4. CONST duzina= 5;
  5. TYPE NIZ= ARRAY [1..duzina] OF CARDINAL;
  6. VAR niz: NIZ;
  7.     i,n,s: CARDINAL;
  8. BEGIN
  9.   WriteString('Unesite 5 brojeva: ');
  10.   WriteLn;
  11.   FOR i:=1 TO duzina DO
  12.     WriteString('broj[');
  13.     WriteCard(i,1);
  14.     WriteString('] = ');
  15.     ReadCard(niz[i]);
  16.   END;
  17.   WriteString('Uneli ste sledece brojeve: ');
  18.   FOR i:=1 TO duzina DO
  19.     WriteCard(niz[i],0);
  20.   END;
  21.   WriteLn;
  22.   WriteString('unesite broj provjeru pripadnosti nizu: ');
  23.   ReadCard(n);
  24.   s:=0;
  25.   FOR i:=1 TO duzina DO
  26.     IF niz[i] = n THEN
  27.       INC(s);
  28.     END;
  29.   END;
  30.   IF s>0 THEN
  31.     WriteString('Broj se nalazi u nizu.');
  32.   ELSE
  33.     WriteString('Broj se ne nalazi u nizu.');
  34.   END;
  35. END rz2_2.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement