fork(2) download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. // your code goes here
  5. return 0;
  6. }
  7. #include<stdio.h>
  8. #include<math.h>
  9.  
  10. #define N 50
  11. #define m 64
  12. #define pi 3.14159265359
  13.  
  14. double f(double x){
  15.  
  16. return sin(x);
  17. }
  18.  
  19. double g(double x){
  20. return sin(-2*x);
  21. }
  22.  
  23. int main(int argc,char**argv){
  24. double h=2.0*pi/64.0;
  25. double k=0.02;
  26. double lambda=k/h;
  27. double l = 2*pi;
  28. double w[m+1][N+1]={0};
  29. w[0][0]=f(0);
  30. w[m][0]=f(l);
  31. int i,j;
  32. for (i=1;i<=m-1;i++){
  33. w[i][0]=f(i*h);
  34. w[i][1]=(1-(lambda*lambda))*f(i*h)+.5*(lambda*lambda)*(f((i+1)*h)+f((i-1)*h))+k*g(i*h);
  35. }
  36. for ( j=1;j<=N-1;j++){
  37. for ( i =1;i<=m-1;i++){
  38. w[i][j+1]=2.0*(1-(lambda*lambda))*w[i][j]+(lambda*lambda)*(w[i+1][j]+w[i-1][j])-w[i][j-1];
  39. }}
  40. for (j=0;j<=N;j++){
  41. double t=j*k;
  42. for ( i =0;i<=m;i++){
  43. double x=i*h;
  44. printf("(x,t,wij,u(x,t))=(%f,%f,%f,%f)\n",x,t,w[i][j],sin(x-2.0*t));
  45. }}
  46. return 0;}
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:23:5: error: conflicting types for 'main'
 int main(int argc,char**argv){
     ^
prog.c:3:5: note: previous definition of 'main' was here
 int main(void) {
     ^
prog.c: In function 'main':
prog.c:28:1: warning: missing braces around initializer [-Wmissing-braces]
 double w[m+1][N+1]={0};
 ^
prog.c:28:1: warning: (near initialization for 'w[0]') [-Wmissing-braces]
stdout
Standard output is empty