是C++代码,才刚把图片熬出锅,还是热的,就放上来了……-
-
- #include<cstdio>
- #include<memory>
-
- char hd[54]={66,77,38,106,0,0,0,0,0,0,54,0,0,0,40,0,0,0,0,8,0,0,0,6,
- 0,0,1,0,24,0,0,0,0,0,-16,105,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
-
- char nm[10][7][4]={
-
- 0,1,1,0,
- 1,0,0,1,
- 1,0,0,1,
- 1,0,0,1,
- 1,0,0,1,
- 1,0,0,1,
- 0,1,1,0,
-
- 0,0,1,0,
- 0,1,1,0,
- 0,0,1,0,
- 0,0,1,0,
- 0,0,1,0,
- 0,0,1,0,
- 0,0,1,0,
-
- 0,1,1,0,
- 1,0,0,1,
- 0,0,0,1,
- 0,0,1,0,
- 0,1,0,0,
- 1,0,0,0,
- 1,1,1,1,
-
- 0,1,1,0,
- 1,0,0,1,
- 0,0,0,1,
- 0,1,1,0,
- 0,0,0,1,
- 1,0,0,1,
- 0,1,1,0,
-
- 0,0,1,0,
- 0,1,1,0,
- 1,0,1,0,
- 1,0,1,0,
- 1,1,1,1,
- 0,0,1,0,
- 0,0,1,0,
-
- 1,1,1,1,
- 1,0,0,0,
- 1,1,1,0,
- 0,0,0,1,
- 0,0,0,1,
- 1,0,0,1,
- 0,1,1,0,
-
- 0,1,1,0,
- 1,0,0,1,
- 1,0,0,0,
- 1,1,1,0,
- 1,0,0,1,
- 1,0,0,1,
- 0,1,1,0,
-
- 1,1,1,1,
- 0,0,0,1,
- 0,0,1,0,
- 0,0,1,0,
- 0,1,0,0,
- 0,1,0,0,
- 0,1,0,0,
-
- 0,1,1,0,
- 1,0,0,1,
- 1,0,0,1,
- 0,1,1,0,
- 1,0,0,1,
- 1,0,0,1,
- 0,1,1,0,
-
- 0,1,1,0,
- 1,0,0,1,
- 1,0,0,1,
- 0,1,1,1,
- 0,0,0,1,
- 1,0,0,1,
- 0,1,1,0
-
- };
-
- char R[12000][600],G[12000][600],B[12000][600];
- int g,h,i,j,k,l,m,ln,c[3][3];
-
- double a[512][513],b[512][513],d;
-
- void pm(int p,int x,int y)
- {
- int i,j,q[3][3];
- for(i=2;i>=0;i--)
- for(j=2;j>=0;j--)
- {
- q[i][j]=p%2;
- p/=2;
- }
- for(i=0;i<10;i++)
- for(j=0;j<10;j++)
- if(i%3&&j%3)
- {
- B[x+i][y+j]=0;
- if(q[i/3][j/3])G[x+i][y+j]=0;
- else R[x+i][y+j]=0;
- }
- else
- {
- R[x+i][y+j]=0;
- G[x+i][y+j]=0;
- B[x+i][y+j]=0;
- }
- }
-
- void pn(int p,int x,int y)
- {
- int i,j;
- for(i=0;i<7;i++)
- for(j=0;j<4;j++)
- if(nm[p][i][j])
- {
- R[x+i][y+j]=0;
- G[x+i][y+j]=0;
- B[x+i][y+j]=0;
- }
- }
-
- void pj(int x,int y)
- {
- R[x][y+1]=0;
- G[x][y+1]=0;
- B[x][y+1]=0;
- R[x+1][y]=0;
- G[x+1][y]=0;
- B[x+1][y]=0;
- R[x+1][y+1]=0;
- G[x+1][y+1]=0;
- B[x+1][y+1]=0;
- R[x+1][y+2]=0;
- G[x+1][y+2]=0;
- B[x+1][y+2]=0;
- R[x+2][y+1]=0;
- G[x+2][y+1]=0;
- B[x+2][y+1]=0;
- }
-
- void pd(int x,int y)
- {
- int i,j;
- for(i=0;i<4;i+=2)
- for(j=0;j<3;j++)
- {
- R[x+i][y+j]=0;
- G[x+i][y+j]=0;
- B[x+i][y+j]=0;
- }
- }
-
- int main()
- {
- memset(R,-1,sizeof(R));
- memset(G,-1,sizeof(G));
- memset(B,-1,sizeof(B));
- FILE *f=fopen("512eqs.bmp","wb");
- hd[18]=88;
- hd[19]=2;
- hd[22]=-32;
- hd[23]=46;
- for(i=0;i<54;i++)
- fprintf(f,"%c",hd[i]);
- ln=1;
- for(h=0;h<512;h++)
- {
- pm(h,ln,16);
- pd(ln+4,27);
- g=0;
- if((h&7)==7||(h&7)==0)g|=7;
- if((h&56)==56||(h&56)==0)g|=56;
- if((h&448)==448||(h&448)==0)g|=448;
- if((h&73)==73||(h&73)==0)g|=73;
- if((h&146)==146||(h&146)==0)g|=146;
- if((h&292)==292||(h&292)==0)g|=292;
- if(!g)
- {
- a[h][h]=1;
- pn(0,ln+2,31);
- ln+=12;
- }
- else
- {
- k=256;
- m=1;
- for(i=0;i<3;i++)
- for(j=0;j<3;j++)
- {
- c[i][j]=0;
- if(h&k)c[i][j]=1;
- if(g&k)
- {
- c[i][j]=-1;
- m+=m;
- }
- k/=2;
- }
- a[h][h]=m;
- a[h][512]=m;
- if(m<9)pn(8,ln+2,11);
- else
- if(m<99)
- {
- pn(m/10,ln+2,6);
- pn(m%10,ln+2,11);
- }
- else
- {
- pn(m/100,ln+2,1);
- pn(m/10%10,ln+2,6);
- pn(m%10,ln+2,11);
- }
- for(j=0;j<3;j++)
- {
- k=2;
- for(i=2;i>=0;i--)
- if(c[i][j]>=0)c[k--][j]=c[i][j];
- for(;k>=0;k--)c[k][j]=-1;
- }
- k=256;
- g=0;
- l=0;
- for(i=0;i<3;i++)
- for(j=0;j<3;j++)
- {
- if(c[i][j]<0)g|=k;
- if(c[i][j]>0)l|=k;
- k/=2;
- }
- j=-1;
- for(i=0;i<512;i++)
- if((i&g)==i)
- {
- a[h][i|l]-=1;
- if(j>=0)pj(ln+4,j*15+27);
- else j=0;
- pm(i|l,ln,j*15+31);
- j++;
- if(j>37)
- {
- j=0;
- ln+=12;
- }
- }
- pj(ln+4,j*15+27);
- if(m<9)pn(8,ln+2,j*15+31);
- else
- if(m<99)
- {
- pn(m/10,ln+2,j*15+31);
- pn(m%10,ln+2,j*15+36);
- }
- else
- {
- pn(m/100,ln+2,j*15+31);
- pn(m/10%10,ln+2,j*15+36);
- pn(m%10,ln+2,j*15+41);
- }
- ln+=12;
- }
- }
- for(i=11999;i>=0;i--)
- for(j=0;j<600;j++)
- fprintf(f,"%c%c%c",B[i][j],G[i][j],R[i][j]);
- fclose(f);
- memcpy(b,a,sizeof(a));
- for(i=0;i<512;i++)
- for(j=i+1;j<512;j++)
- {
- for(k=i+1;k<513;k++)
- a[j][k]-=a[i][k]*a[j][i]/a[i][i];
- a[j][i]=0;
- }
- for(i=511;i>=0;i--)
- {
- for(j=i+1;j<512;j++)
- {
- a[i][512]-=a[j][512]*a[i][j];
- a[i][j]=0;
- }
- a[i][512]/=a[i][i];
- a[i][i]=1;
- }
- for(i=0;i<512;i++)
- {
- printf("%d: %.16lf ",i,a[i][512]);
- d=0;
- for(j=0;j<512;j++)
- d+=a[j][512]*b[i][j];
- printf("%lf %lf\n",d,b[i][512]);
- }
- f=fopen("512sols.bmp","wb");
- memset(R,-1,sizeof(R));
- memset(G,-1,sizeof(G));
- memset(B,-1,sizeof(B));
- for(i=0;i<54;i++)
- fprintf(f,"%c",hd[i]);
- ln=1;
- for(h=0;h<512;h++)
- {
- pm(h,ln,1);
- pd(ln+4,12);
- d=a[h][512];
- pn(int(d),ln+2,16);
- R[ln+8][21]=0;
- G[ln+8][21]=0;
- B[ln+8][21]=0;
- for(j=23;j<103;j+=5)
- {
- d=(d-int(d))*10;
- pn(int(d),ln+2,j);
- }
- ln+=12;
- }
- for(i=11999;i>=0;i--)
- for(j=0;j<600;j++)
- fprintf(f,"%c%c%c",B[i][j],G[i][j],R[i][j]);
- fclose(f);
- return 0;
- }
-
复制代码 |