Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so dont bother with any of their useless mail servers here and just use oauth login instead. Thank the nice Russians for causing that. :)
Paste
Pasted as C by registered user henriquerm ( 14 years ago )
#include <stdio.h>
#include <math.h>
double Loop(int x);
double Calculo(int y);
double Loop2(int z);
int l, I=0, J=0, X=0, Y=0, i;
double rede[1000][1000];
double E, M, K=1;
main()
{
printf("Digite o numero l de largura/altura da rede\n");
scanf("%d" , &l);
Loop(l);
}
double Loop ( int x ) {
for (i=-1; i<=1; i=i+2){
rede[I][J]=i; //Coloca um elemento da matriz como i
printf("%d %d %d\n", I, J, i);
if (I==x-1 && J==x-2){J++;Loop2(l);} //quando chegar no penultimo elemento da rede, andar mais um pro lado e fazer o loop2.
else {
if (J==x-1 && I!= x-1){
I++;J=0; Loop(x);
}
else {
J++; Loop(x);
}
}
}
}
double Calculo (int y) {
for (X=0;X<=y-1;X++) {
for (Y=0; Y<=y-1; Y++) {
if (X == y-1 && Y == y-1){
E = E + K * rede[X][Y] * (rede[X][0] + rede [0][Y]);
}
else {
if (X==y-1) {
E = E + K * rede[X][Y] * (rede[X+1][Y] + rede[X][0]);
}
else {
if (Y==y-1) {
E = E + K * rede[X][Y] * (rede[0][Y] + rede[X][Y+1]);
}
else {
E = E + K * rede[X][Y] * (rede[X][Y] + rede[X][Y+1]);
}
}
}
M = M + rede[X][Y];
}
}
printf ("%lf %lf\n", E, M);
}
double Loop2(int z) {
for (i=-1; i<=1; i+=2){
printf("%d\%d %d\n", I, J, i);
rede[I][J]=i;
Calculo(l);
}
}
Revise this Paste
Parent: 46370