fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. static double f(double x,double y){
  11. //return Math.exp(-x*x-y*y);
  12. return x*x+y*y;
  13. }
  14. public static void main (String[] args) throws java.lang.Exception
  15. {
  16. // your code goes here
  17. double x,y,s=0.0,d=0.001;
  18. for(x=-1.0;x<=1.0;x+=d){
  19. for(y=-1.0;y<=1.0;y+=d){
  20. if(x*x+y*y<=1.0)
  21. s+=f(x,y)*d*d;
  22. }
  23. }
  24. System.out.println(s);
  25. }
  26. }
Success #stdin #stdout 0.1s 33136KB
stdin
Standard input is empty
stdout
1.5707326956720782