Advertisement
volkovich_maksim

t_14_29_a_v1_volkovich

Nov 16th, 2015
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.65 KB | None | 0 0
  1. {Волкович Максим (volkovcih.maksim.s@gmail.com), 112гр., v1.0,
  2. описать функцию, подсчитывающую количество разлиных элементов в массиве V типа T1}
  3. program t_14_29_a (input,output);
  4. const n=20;
  5. type T1 = array[1..n] of 0..999;
  6. var V:T1; i:integer;
  7. function diff(a:T1):integer;
  8.   var t:set of 0..999; i,count:integer;
  9.   begin
  10.     t:=[]; count:=0;
  11.     for i:=1 to n do
  12.       if not(a[i] in t) then
  13.       begin
  14.         count:=count+1;  
  15.         t:=t+[a[i]];
  16.       end;
  17.     diff:=count;    
  18.   end;  
  19. begin
  20.   for i:=1 to n do read(V[i]);
  21.   writeln(diff(V));
  22. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement