-
-
Save siddhant3s/613961 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cmath> | |
using namespace std; | |
int main() { | |
const int x_max=20 ,y_max=20; | |
const float y_max_v=1.0, mu=1.0; | |
float V[x_max][y_max]; | |
for (int i=0; i<=y_max-1; i++) { | |
V[0][i]=0.0; | |
V[x_max-1][i]=1.0; | |
} | |
for (int i=0; i<=x_max-1;i++){ | |
V[i][0]=(y_max_v/(y_max-1))*i; | |
V[i][y_max-1]=(y_max_v/(y_max-1))*i; | |
} | |
for(int i=1;i<=x_max-2;i++) { | |
for(int j=1;j<=y_max-2;j++) {V[i][j]=mu;} | |
} | |
while(2>1){ | |
for(int i=1;i<=x_max-2;i++) { cout<<"hello"; | |
for(int j=1;j<=y_max-2;j++) { cout<<"BOOO"; | |
if(fabs((V[i+1][j]+V[i-1][j]+V[i][j+1]+V[i][j-1])/4.0)-V[i][j]>=0.000005) {"KITE!"; | |
V[i][j]=(V[i+1][j]+V[i-1][j]+V[i][j+1]+V[i][j-1])/4.0; | |
} | |
else {cout<<"The solution is "<<V[i][j]; break;} | |
} | |
} | |
} | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment