richie3366

idiots v1

Oct 3rd, 2012
451
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ada 0.89 KB | None | 0 0
  1. ----------------------------------------------------------------
  2. --  *  idiots.adb
  3. --  *  Role : trouver tous les nombres "idiots" entre 1 et 1000
  4. --  *  Basé sur chiffres.adb
  5. ----------------------------------------------------------------
  6. with entrees_sorties; use entrees_sorties;
  7.  
  8. procedure idiots is
  9.   nombreCourant : Integer;
  10.   nombreModif : Integer;
  11.   resultat : Integer;
  12. begin
  13.  
  14.   nombreCourant := 1;
  15.  
  16.   while(nombreCourant <= 1000) loop
  17.  
  18.     nombreModif := nombreCourant;
  19.  
  20.     resultat := 0;
  21.  
  22.     while(nombreModif > 0) loop
  23.       resultat := resultat + ((nombreModif) mod 10)**3;
  24.       nombreModif := (nombreModif - (nombreModif mod 10))/10;
  25.     end loop;
  26.  
  27.     if(nombreCourant = resultat) then
  28.       put(nombreCourant, 0);
  29.       put(" est un nombre idiot.");
  30.       new_line;
  31.     end if;
  32.    
  33.     nombreCourant := nombreCourant + 1;
  34.  
  35.   end loop;
  36. end idiots;
Advertisement
Add Comment
Please, Sign In to add comment