Guest User

Untitled

a guest
Apr 19th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <malloc.h>
  5. #include <ogcsys.h>
  6. #include <gccore.h>
  7. #include <math.h>
  8.  
  9. static void *xfb = NULL;
  10. static GXRModeObj *rmode = NULL;
  11.  
  12. int main(int argc, char **argv) {
  13.  
  14. VIDEO_Init();
  15. PAD_Init();
  16.  
  17. switch(VIDEO_GetCurrentTvMode()) {
  18. case VI_NTSC:
  19. rmode = &TVNtsc480IntDf;
  20. break;
  21. case VI_PAL:
  22. rmode = &TVPal528IntDf;
  23. break;
  24. case VI_MPAL:
  25. rmode = &TVMpal480IntDf;
  26. break;
  27. default:
  28. rmode = &TVNtsc480IntDf;
  29. break;
  30. }
  31.  
  32. xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
  33. console_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ);
  34.  
  35. VIDEO_Configure(rmode);
  36. VIDEO_SetNextFramebuffer(xfb);
  37. VIDEO_SetBlack(FALSE);
  38. VIDEO_Flush();
  39. VIDEO_WaitVSync();
  40. if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();
  41.  
  42. double r=0, x=1, y=0, s=0, a=0, p=0;
  43. printf("\n\n***************************************************************\n\n");
  44. printf("Give radius much much greater than 1\nRadius = ");
  45. scanf("%lf",&r);
  46. while(x<=r)
  47. {
  48. y=sqrt(r*r- x*x);
  49. s=s+y;
  50. x=x+1;
  51. }
  52. a=(s*4);
  53. p=a/(r*r);
  54. printf("Pi = %1.10lf",p);
  55. printf("\n\n***************************************************************\n\n");
  56. getchar();
  57. return 0;
  58.  
  59. while(1) {
  60.  
  61. VIDEO_WaitVSync();
  62. }
  63.  
  64. }
Add Comment
Please, Sign In to add comment