Advertisement
Guest User

Untitled

a guest
Feb 28th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. public class rerata{
  2. public static void main(String [] args){
  3. int a[] = new int[10];
  4. long start, finish;
  5. double waktu, rata2;
  6. int jumlah = 0;
  7.  
  8. for (int i=0;i<a.length;i++){
  9. a[i]=i+5;
  10. }
  11. start = System.nanoTime();
  12.  
  13. for(int i=0;i<a.length;i++){
  14. jumlah += a[i];
  15. }
  16.  
  17. rata2 = jumlah/a.length;
  18. System.out.println("Rata-Rata : " +rata2);
  19. finish = System.nanoTime();
  20. waktu = finish-start;
  21. waktu = waktu/10000000;
  22. System.out.println("lama waktu : "+waktu);
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement