fork download
  1. #include <iostream.h>
  2. #include <stdio.h>
  3. #include <math.h>
  4. #include <stdlib.h>
  5. #include <windows.h>
  6. #include <iomanip.h>
  7.  
  8.  
  9. void main()
  10. {
  11. int n,i,k;
  12. float h,c1,c2,c,d1,d2,d,fx,a,b,k1,k2,m,H,runge;
  13. float p[9999],q[9999],betta[9999],gamma[9999],fi[9999],alfa[9999];
  14. float y[9999],u[9999],v[9999],x[9999],Y[9999];
  15. c1=d1=1.0;
  16. c2=d2=1.0;
  17. fx=0.0;
  18. cout<<"Vvedite kraia otrezka [a,b] i 4islo uzlov n"<<endl;
  19. cout<<endl<<"a=";
  20. cin>>a;
  21. cout<<endl<<"b=";
  22. cin>>b;
  23. cout<<endl<<"n=";
  24. cin>>n; cout<<endl<<"A tak ge parametri c,d,k1,k2,m"<<endl;
  25. cin>>c>>d>>k1>>k2>>m;
  26. x[0]=a;
  27. h=(b-a)/n;
  28. betta[0]=c1*h-c2;
  29. gamma[0]=c2;
  30. fi[0]=h*c;
  31. alfa[0]=0;
  32. for(i=1;i<n;i++)
  33. {
  34. x[i]=x[i-1]+h;
  35. p[i]=(k1+k2*x[i])/(x[i]*x[i]-1);
  36. q[i]=m/sqrt(1-x[i]*x[i]);
  37. fi[i]=fx*h*h;
  38. alfa[i]=1-(1/2)*p[i];
  39. betta[i]=q[i]*h*h-2;
  40. gamma[i]=1+(1/2)*p[i]*h;
  41. }
  42. alfa[n]=-d2;
  43. betta[n]=h*d1+d2;
  44. fi[n]=h*d;
  45. v[0]=gamma[0]/betta[0];
  46. u[0]=fi[0]/betta[0];
  47. for(i=1;i<n;i++)
  48. {
  49. v[i]=-gamma[i]/(betta[i]+alfa[i]*v[i-1]);
  50. u[i]=(fi[i]-alfa[i]*u[i-1])/(betta[i]+alfa[i]*v[i-1]);
  51. }
  52. y[n]=u[n];
  53. for(i=n-1;i>0;i--)
  54. y[i]=u[i]+v[i]*y[i+1];
  55. cout<<" i"<<" x "<<" y"<<endl;
  56. for(i=0;i<n;i++)
  57. {
  58. cout.width(4);
  59. cout<<i;
  60. cout.width(5);
  61. cout<<x[i];
  62. cout.width(14);
  63. cout<<y[i]<<endl;
  64. }
  65.  
  66. H=(b-a)/(2*n);
  67. betta[0]=c1*H-c2;
  68. gamma[0]=c2;
  69. fi[0]=H*c;
  70. alfa[0]=0;
  71. k=2*n;
  72. for(i=1;i<k;i++)
  73. {
  74. x[i]=x[i-1]+H;
  75. p[i]=(k1+k2*x[i])/(x[i]*x[i]-1);
  76. q[i]=m/sqrt(1-x[i]*x[i]);
  77. fi[i]=fx*H*H;
  78. alfa[i]=1-(1/2)*p[i];
  79. betta[i]=q[i]*H*H-2;
  80. gamma[i]=1+(1/2)*p[i]*H;
  81. }
  82. alfa[k]=-d2;
  83. betta[k]=H*d1+d2;
  84. fi[k]=H*d;
  85. v[0]=gamma[0]/betta[0];
  86. u[0]=fi[0]/betta[0];
  87. for(i=1;i<k;i++)
  88. {
  89. v[i]=-gamma[i]/(betta[i]+alfa[i]*v[i-1]);
  90. u[i]=(fi[i]-alfa[i]*u[i-1])/(betta[i]+alfa[i]*v[i-1]);
  91. }
  92. Y[k]=u[k];
  93. for(i=2*n-1;i>0;i--)
  94. Y[i]=u[i]+v[i]*Y[i+1];
  95. cout<<" i"<<" x "<<" Y"<<endl;
  96. for(i=0;i<k;i++)
  97. {
  98. cout.width(4);
  99. cout<<i;
  100. cout.width(5);
  101. cout<<x[i];
  102. cout.width(14);
  103. cout<<Y[i]<<endl;
  104. }
  105. cout<<"pogre6nost' po pravily runge:"<<endl;
  106. for(i=0;i<n;i++)
  107. {
  108. runge=(Y[2*i]-y[i]);
  109. cout<<runge<<endl;
  110. }
  111. system("PAUSE");
  112. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
#include <iostream.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <windows.h>
#include <iomanip.h>


void main()
{
	int n,i,k;
	float h,c1,c2,c,d1,d2,d,fx,a,b,k1,k2,m,H,runge;
	float p[9999],q[9999],betta[9999],gamma[9999],fi[9999],alfa[9999];
	float y[9999],u[9999],v[9999],x[9999],Y[9999];
	c1=d1=1.0;
	c2=d2=1.0;
	fx=0.0;
	cout<<"Vvedite kraia otrezka [a,b] i 4islo uzlov n"<<endl;
	cout<<endl<<"a=";
	cin>>a;
	cout<<endl<<"b=";
	cin>>b;
	cout<<endl<<"n=";
	cin>>n; cout<<endl<<"A tak ge parametri c,d,k1,k2,m"<<endl;
	cin>>c>>d>>k1>>k2>>m;
	x[0]=a;
	h=(b-a)/n;
	betta[0]=c1*h-c2;
	gamma[0]=c2;
	fi[0]=h*c;
	alfa[0]=0;
	for(i=1;i<n;i++)
	{
		x[i]=x[i-1]+h;
		p[i]=(k1+k2*x[i])/(x[i]*x[i]-1);
		q[i]=m/sqrt(1-x[i]*x[i]);
		fi[i]=fx*h*h;
		alfa[i]=1-(1/2)*p[i];
		betta[i]=q[i]*h*h-2;
		gamma[i]=1+(1/2)*p[i]*h;
	}
	alfa[n]=-d2;
	betta[n]=h*d1+d2;
	fi[n]=h*d;
	v[0]=gamma[0]/betta[0];
	u[0]=fi[0]/betta[0];
	for(i=1;i<n;i++)
	{
		v[i]=-gamma[i]/(betta[i]+alfa[i]*v[i-1]);
		u[i]=(fi[i]-alfa[i]*u[i-1])/(betta[i]+alfa[i]*v[i-1]);
	}
	y[n]=u[n];
	for(i=n-1;i>0;i--) 
		y[i]=u[i]+v[i]*y[i+1];
	cout<<"   i"<<"  x  "<<"     y"<<endl;
	for(i=0;i<n;i++)
	{
		cout.width(4);
		cout<<i;
		cout.width(5);
		cout<<x[i];
		cout.width(14);
		cout<<y[i]<<endl;
	}

	H=(b-a)/(2*n);
	betta[0]=c1*H-c2;
	gamma[0]=c2;
	fi[0]=H*c;
	alfa[0]=0;
	k=2*n;
	for(i=1;i<k;i++)
	{
		x[i]=x[i-1]+H;
		p[i]=(k1+k2*x[i])/(x[i]*x[i]-1);
		q[i]=m/sqrt(1-x[i]*x[i]);
		fi[i]=fx*H*H;
		alfa[i]=1-(1/2)*p[i];
		betta[i]=q[i]*H*H-2;
		gamma[i]=1+(1/2)*p[i]*H;
	}
	alfa[k]=-d2;
	betta[k]=H*d1+d2;
	fi[k]=H*d;
	v[0]=gamma[0]/betta[0];
	u[0]=fi[0]/betta[0];
	for(i=1;i<k;i++)
	{
		v[i]=-gamma[i]/(betta[i]+alfa[i]*v[i-1]);
		u[i]=(fi[i]-alfa[i]*u[i-1])/(betta[i]+alfa[i]*v[i-1]);
	}
	Y[k]=u[k];
	for(i=2*n-1;i>0;i--) 
		Y[i]=u[i]+v[i]*Y[i+1];
	cout<<"   i"<<"  x  "<<"     Y"<<endl;
	for(i=0;i<k;i++)
	{
		cout.width(4);
		cout<<i;
		cout.width(5);
		cout<<x[i];
		cout.width(14);
		cout<<Y[i]<<endl;
	}
	cout<<"pogre6nost' po pravily runge:"<<endl;
	for(i=0;i<n;i++)
	{
		runge=(Y[2*i]-y[i]);
		cout<<runge<<endl;
	}
	system("PAUSE");
}
compilation info
prog.cpp:1:22: fatal error: iostream.h: No such file or directory
 #include <iostream.h>
                      ^
compilation terminated.
stdout

Standard output is empty