richie3366

exemple traçage joli

Oct 9th, 2012
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ada 0.80 KB | None | 0 0
  1. with entrees_sorties; use entrees_sorties;
  2. procedure un is
  3.    n, c, i, nb, pi : Integer;
  4.    
  5.    procedure trace(num : in Integer) is
  6.    begin
  7.       new_line;
  8.       put("[trace "&Integer'Image(num)&"]/[n="&Integer'Image(n)&"][c="&Integer'Image(c)&"][i="&Integer'Image(i)&"][nb="&Integer'Image(nb)&"][pi="&Integer'Image(pi)&"]");
  9.       new_line;
  10.    end trace;
  11.  
  12. begin -- Algorithme5
  13.    get(n);
  14.    c := 0;
  15.    i := 1;  trace(1);--1
  16.    while i <= n loop
  17.       get(nb);      trace(2);--2
  18.       if nb mod 2 = 1 then
  19.          if c = 0 then
  20.             pi := nb;
  21.             c := 1;     trace(3);--3
  22.          else
  23.             c := c + 1;     trace(4);--4
  24.          end if;
  25.       end if;
  26.       i := i + 1;       trace(5);--5
  27.    end loop;
  28.    put("PI = ");put(pi); new_line;
  29.    put("C = ");put(c);
  30. end un; -- Algorithme5
Advertisement
Add Comment
Please, Sign In to add comment