Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <malloc.h>
- #include <ogcsys.h>
- #include <gccore.h>
- #include <math.h>
- static void *xfb = NULL;
- static GXRModeObj *rmode = NULL;
- int main(int argc, char **argv) {
- VIDEO_Init();
- PAD_Init();
- switch(VIDEO_GetCurrentTvMode()) {
- case VI_NTSC:
- rmode = &TVNtsc480IntDf;
- break;
- case VI_PAL:
- rmode = &TVPal528IntDf;
- break;
- case VI_MPAL:
- rmode = &TVMpal480IntDf;
- break;
- default:
- rmode = &TVNtsc480IntDf;
- break;
- }
- xfb = MEM_K0_TO_K1(SYS_AllocateFramebuffer(rmode));
- console_init(xfb,20,20,rmode->fbWidth,rmode->xfbHeight,rmode->fbWidth*VI_DISPLAY_PIX_SZ);
- VIDEO_Configure(rmode);
- VIDEO_SetNextFramebuffer(xfb);
- VIDEO_SetBlack(FALSE);
- VIDEO_Flush();
- VIDEO_WaitVSync();
- if(rmode->viTVMode&VI_NON_INTERLACE) VIDEO_WaitVSync();
- double r=0, x=1, y=0, s=0, a=0, p=0;
- printf("\n\n***************************************************************\n\n");
- printf("Give radius much much greater than 1\nRadius = ");
- scanf("%lf",&r);
- while(x<=r)
- {
- y=sqrt(r*r- x*x);
- s=s+y;
- x=x+1;
- }
- a=(s*4);
- p=a/(r*r);
- printf("Pi = %1.10lf",p);
- printf("\n\n***************************************************************\n\n");
- getchar();
- return 0;
- while(1) {
- VIDEO_WaitVSync();
- }
- }
Add Comment
Please, Sign In to add comment