| | |
run program
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Jan 2008
Posts: 1
Reputation:
Solved Threads: 0
please somebody run this program
i have problem with #include <graphics.h>
i have problem with #include <graphics.h>
c Syntax (Toggle Plain Text)
#include <stdio.h> #include <math.h> #include <graphics.h> #include <conio.h> Void DrawFunction (int Npoint, double data[], double H) ;/* Display results */ Void MakePotential (int Npoint, double x0, double dx, double V0, double v[], double vd[]) ; /*potential*/ Void MakePacket (int Npoint, double x0, double dx, double k0, double *norm1, double yr[], double yi[]) ; /*make wavepacket*/ Void TimeIntegral (int Npoint, double dx2, double dt, double *norm2, double yr[], double yi[], double yd[], double v[], double a[], double b[]); double a[4] = {0.0, 0.5, 0.5, 1.0}; double b[4] = {1/6.0, 1/3.0, 1/3.0, 1/6.0}; double yr[401],yi[401],yd[401],v[401],vd[401]; double kr[401],ki[401],dyr[401],dyi[401],ykr[401],yki[401]; void main(void) { int t, I, itest, Nmax; double V0, x0, x, dx, dx2, dt, k0, E, norm1, norm2; int graphriver = DETECT, graphmode; initgraph( &graphriver, &graphmode , “ “); setviewport(200, 50, 600, 350, 1); rectangle(0,0,400,300); dx = 0.02; Nmax = 400; dx2 = dx*dx; dt = dx2/2.0; x0 = 0.0; V0 = 400.0; MakePotential (Nmax, x0, dx, V0, v, vd); DrawFunction (Nmax, vd, 0); Gotoxy(1,1); printf(“Input wave number (k0<25) ! “); scanf(“%1f”, &k0); E=k0*ko; printf(“ Time Norm”); norm 1=0; MakePacket(Nmax, x0, dx, k0, &norm1, yr, yi); norm2=norm1; for( t=0; t<=600; t++) { gotoxy(1,3); printf(“%5d %8.41f”,t, norm2/norm1); printf(“%d \n”,t); TimeIntegral (Nmax, dx2,dt, %norm2, yr,yi,yd,v,a,b); itest=fmod(t,10); if (itest==0) { clearviewport(); rectangle(0,0,400,300); setcolor(4); DrawFunction (Nmax,yr,E/V0); setcolor(1); DrawFunction (Nmax,yr,E/V0); setcolor(7); DrawFunction (Nmax,yr,E/V0); DrawFunction (Nmax,vd,0); } } printf(“ Calculation ends,if ready, please return key!”); getche(); closegraph(); } /* -- End of main function -- */ void DrawFunction(int Npoint,double data[], double H) { int n, iy + moveto(0,250-(data[0]+H)*100); for( n=0; n<=Npoint-1; n++) { iy=250-(data[n]+H*100; lineto(n, iy); } } void MakePotential (int Npoint,double x0, double dx, double V0,double v[], double vd[]) { int n; double x; x=x0 ; for ( n=0; n<=Npoint-1; n++ ) { if (n<220) vd[n]=0 ;else if (n>230) vd[n]=0; else vd[n]=1.0; v[n]=V0*vd[n]; x+=dx; } } void MakePacket (int Npoint,double x0, double dx, double k0, double *norm1, double yr[], double yi[]) { int n; double x; x=x0 ; for ( n=0; n<=Npoint-1; n++ ) { yr[n]= cos(k0*x}*exp(-(x-2.5)*(x-2.5)*3.0) ; yi[n]= sin(k0*x}*exp(-(x-2.5)*(x-2.5)*3.0) ; x+=dx; *norm1=norm1+yr[n]*yr[n]+yi[n]*yi[n]; } } void TimeIntegralt (int Npoint,double dx2, double dt, double *norm2, double yr[], double yi[], double yd[], double v[], double a[], double b[]) { int nx,ij ; for ( nx=0; nx<=Npoint; nx++ ) { dyr[nx] = 0.0; dyi[nx] = 0.0 ; kr[nx] = 0.0; ki[nx] = 0.0; } for ( ij=0 ;ij<=3 ;ij++) /* I loop */ { for ( nx=0; nx<=Npoint; nx++ ) { ykr[nx]= yr[nx] + a[ij]*kr[nx] ; yki[nx]= yi[nx] + a[ij]*ki[nx] ; } for ( nx=1; nx<=Npoint-1; nx++ ) { kr[nx]=-((yki[nx+1]-2.0*yki[nx]+yki[nx-1])/dx2-v[nx]*yki[nx])*dt; ki[nx]=-((ykr[nx+1]-2.0*ykr[nx]+ykr[nx-1])/dx2-v[nx]*yki[nx])*dt; } for ( nx=0; nx<=Npoint; nx++ ) { dyr[nx] = dyr[nx] + b[ij]*kr[nx] ; dyi[nx] = dyi[nx] + b[ij]*ki[nx] ; } } /* i-loop end */ *norm2=0.0; for ( nx=0; nx<=Npoint; nx++ ) { yr[nx] = yr[nx] + dyr[nx]; yi[nx] = yi[nx] + dyi[nx]; yd[nx] = yr[nx]*yr[nx]+yi[nx]*yi[nx]; *norm2=*norm2+yd[nx] ; } }
Last edited by Ancient Dragon; Jan 23rd, 2008 at 8:07 am. Reason: add code tags
![]() |
Similar Threads
- How can i run this program from a jar. (Java)
- How to run c++ program through command prompt? (C++)
- run program and rename file script help please (Shell Scripting)
- Bus Error when I run my C++ program (C++)
- how can i disable this security to run my program (Windows NT / 2000 / XP)
- Error message when I run my program in C++ (C++)
- Shortcut to Stop the Program (Visual Basic 4 / 5 / 6)
- How to develop a new program (C++)
- Getting an Older Program to Run on Windows XP (Windows tips 'n' tweaks)
Other Threads in the C Forum
- Previous Thread: display array element with passing value...no undesstand~help
- Next Thread: compiler
| Thread Tools | Search this Thread |
#include * ansi append array arrays asterisks bash binarysearch centimeter changingto char character convert copyimagefile cprogramme creafecopyofanytypeoffileinc createprocess() database dynamic execv fgets file floatingpointvalidation fork framework function getlogicaldrivestrin givemetehcodez grade gtkwinlinux hacking histogram ide inches include infiniteloop initialization input interest intmain() iso kernel keyboard kilometer km license linked linkedlist linux list lists looping lowest matrix meter microsoft number oddnumber open opendocumentformat openwebfoundation overwrite owf pdf pointer pointers posix power probleminc process program programming radix recursion recv recvblocked research reversing segmentationfault sequential single socket socketprogramming standard strchr string suggestions systemcall test testing threads turboc unix urboc user variable wab whythiscodecausesegmentationfault windowsapi






