Skip to content

Instantly share code, notes, and snippets.

@alexg228
Created November 19, 2010 07:11
Show Gist options
  • Save alexg228/706217 to your computer and use it in GitHub Desktop.
Save alexg228/706217 to your computer and use it in GitHub Desktop.
fkdlajkkl;ajkdf
#include <iostream>
#include <fstream>
#include <math.h>
using namespace std;
int main(void) {
ofstream fp5;
fp5.open ("Laplace100.txt");
int Max(11);
double V[20000];
double diff(1.0);
V[1]=0;
V[2]=7;
V[3]=25;
V[4]=32;
V[5]=39;
V[6]=42;
V[7]=55;
V[8]=70;
V[9]=82;
V[10]=93;
V[11]=100;
while (diff >= .01) {
for(int i = Max; i > 1; i--) {
V[2*i-1] = V[i];
}
Max = 2*Max-1;
for(int j = 2; j< Max; j=j+2) {
V[j] =.5*(V[j-1]+V[j+1]);
}
diff= fabs(V[5]-V[4]);
}
for(int k=1; k<=Max; k++) {
fp5 << k << " " << V[k] << endl;
}
fp5.close();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment