michael_hartman_cz

PedF UK - OKB1319306 Zkouškový úkol 4 - Čísla

Jan 27th, 2015
497
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.62 KB | None | 0 0
  1. package cisla;
  2. public class Cisla {
  3.    
  4.     public static void vypis () {
  5.         int r = (int) Math.round(99999 * Math.random())+1;
  6.         System.out.println("cislo: " + r);
  7.         String[] vypis = new String[5];
  8.        
  9.         int d = 10000, c;
  10.         for (int i = vypis.length - 1; i >= 0; --i) {
  11.             c = r / d;
  12.             r -= c * d;
  13.             vypis[i] = d + "\t=" + c;
  14.             d /= 10;
  15.         }
  16.  
  17.         for (int i = 0; i < vypis.length; ++i ) {
  18.             System.out.println(vypis[i]);
  19.         }
  20.     }
  21.     public static void main(String[] args) {
  22.         Cisla.vypis();
  23.     }    
  24. }
Advertisement
Add Comment
Please, Sign In to add comment