Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as C by registered user yara ( 15 years ago )
#include <stdio.h>
#include <math.h>
main()
{
int l, c, i, j, s, r, a, b, spin;
printf("Numero de spins da rede\n");
scanf("%d", &s);
r = sqrt(s);
c = l = r;
if(c*l!=s) {
printf("A rede nao e' quadrada\n");
}
else {
printf("-> Rede de spins\n");
int matriz[l][c];
spin = 1;
for(i=1;i<=l;i++) {
for(j=1;j<=c;j++){
for(a=1;a<=l;a++){
for(b=1;b<=c;b++){
if(i==a && j==b) { matriz[i][j] = 0;}
else {
matriz[i][j] = spin;
}
}
}
}
}
for(i=1;i<=l;i++) {
for(j=1;j<=c;j++) {
for(a=1;a<=l;a++) {
for(b=1;b<=c;b++) {
printf("=", matriz[i][j]);
}
printf("\n");
}
printf("\n");
}
}
return 0;
}
}
Revise this Paste