Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Example program
- #include <iostream>
- #include <string>
- #include <math.h>
- using namespace std;
- int Ts(int mass[][16]) {
- int k = 0; int j=0;
- for (int i = 0; i < 16; i++) {
- if (mass[j][i] == 1) {
- k++;
- }
- }
- if (k != 8) {
- return 0;
- }
- else {
- k = 15;
- for (int i = 0; i < 8;i++) {
- if (mass[j][i] == mass[j][k]) {
- return 0;
- }
- k--;
- }
- }
- return 1;
- }
- int Tl(int mass[][16]) {
- bool arr[16][16];
- for (int i = 0; i < 16; i++) {
- arr[0][i] = mass[i];
- }
- for (int i = 1; i < 16; i++) {
- for (int j = 0; j < 15; j++) {
- if (arr[i - 1][j] != arr[i - 1][j + 1]) {
- arr[i][j] = 1;
- }
- else {
- arr[i][j] = 0;
- }
- }
- }
- for (int i = 0; i < 16; i++) {
- if (arr[i][0] == 1) {
- if (i == 0 || i == 1 || i == 2 || i == 4 || i == 8) {
- }
- else {
- return 0;
- }
- }
- }
- return 1;
- }
- int To(int a, int b, int c, int d, int s)
- {
- if (s == 1)
- {
- return a*c + a*(c+1);
- }
- if (s == 2)
- {
- return b*(c+1)*d + (b+1)*c*(d+1);
- }
- if (s == 3)
- {
- return (a+1)*(b+1)*(c+1)*(d+1) + (a+1)*(b+1)*c*d + (a+1)*b*(c+1)*d + (a+1)*b*c*(d+1) ;
- }
- }
- int T1(int a, int b, int c, int d, int s)
- {
- if (s == 1)
- {
- return a*c + a*(c-1);
- }
- if (s == 2)
- {
- return b*(c-1)*d + (b-1)*c*(d-1);
- }
- if (s == 3)
- {
- return (a-1)*(b-1)*(c-1)*(d-1) + (a-1)*(b-1)*c*d + (a-1)*b*(c-1)*d + (a-1)*b*c*(d-1) ;
- }
- }
- int Tm(int s, int mas[][16])
- {int a,b,c,d;
- int i,j;
- if (s == 1)
- { i=0; j=3;
- a=mas[i][j];
- c=mas[i+1][j];
- int k1, k2, l1, l2;
- if(c==1){
- k1=a*c + a*(c-1);
- } else { k1=a*c + a*(c+1); }
- a=mas[i][j-1];
- c=mas[i+1][j-1];
- if(c==1){
- k2=a*c + a*(c-1);
- } else { k2=a*c + a*(c+1); }
- a=mas[i][j-2];
- c=mas[i+1][j-2];
- if(c==1){
- l1=a*c + a*(c-1);
- } else { l1=a*c + a*(c+1); }
- a=mas[i][j-3];
- c=mas[i+1][j-3];
- if(c==1){
- l2=a*c + a*(c-1);
- } else { l2=a*c + a*(c+1); }
- if(((k1-l1) >= 0)&&((k2 - l2 ) >= 0))
- {return 1;} else {return 0;}
- }
- if (s == 2)
- { int k1, k2, l1, l2, k3, k4, l3, l4;
- i=0; j=7;
- b=mas[i][j];
- c=mas[i+1][j];
- d=mas[i+2][j];
- k1=b*(c-1)*d + (b-1)*c*(d-1); b=mas[i][j-1]; c=mas[i+1][j-1]; d=mas[i+2][j-1];
- k2=b*(c-1)*d + (b-1)*c*(d+1); b=mas[i][j-2]; c=mas[i+1][j-2]; d=mas[i+2][j-2];
- k3=b*(c+1)*d + (b-1)*c*(d-1); b=mas[i][j-3]; c=mas[i+1][j-3]; d=mas[i+2][j-3];
- k4=b*(c+1)*d + (b-1)*c*(d+1); b=mas[i][j-4]; c=mas[i+1][j-4]; d=mas[i+2][j-4];
- l1=b*(c+1)*d + (b+1)*c*(d+1); b=mas[i][j-5]; c=mas[i+1][j-5]; d=mas[i+2][j-5];
- l2=b*(c+1)*d + (b+1)*c*(d+1); b=mas[i][j-6]; c=mas[i+1][j-6]; d=mas[i+2][j-6];
- l3=b*(c-1)*d + (b+1)*c*(d+1); b=mas[i][j-7]; c=mas[i+1][j-7]; d=mas[i+2][j-7];
- l4=b*(c-1)*d + (b+1)*c*(d-1);
- if(((k1-l1) >= 0)&&((k2 - l2 ) >= 0)&&((k3-l3) >= 0)&&((k4 - l4 ) >= 0))
- {return 1;} else {return 0;}
- }
- if (s == 3)
- { int k1, k2, l1, l2, k3, k4, l3, l4, k5, k6, l5, l6, k7, k8, l7, l8;
- int a,b,c,d;
- i=0; j=15;
- a=mas[i][j];
- b=mas[i+1][j];
- c=mas[i+2][j];
- d=mas[i+2][j];
- k1=(a-1)*(b-1)*(c-1)*(d-1) + (a-1)*(b-1)*c*d + (a-1)*b*(c-1)*d + (a-1)*b*c*(d-1); a=mas[i][j-1]; b=mas[i+1][j-1]; c=mas[i+2][j-1]; d=mas[i+3][j-1];
- k2=(a-1)*(b-1)*(c-1)*(d+1) + (a-1)*(b-1)*c*d + (a-1)*b*(c-1)*d + (a-1)*b*c*(d+1); a=mas[i][j-2]; b=mas[i+1][j-2]; c=mas[i+2][j-2]; d=mas[i+3][j-2];
- k3=(a-1)*(b-1)*(c+1)*(d-1) + (a-1)*(b-1)*c*d + (a-1)*b*(c+1)*d + (a-1)*b*c*(d-1); a=mas[i][j-3]; b=mas[i+1][j-3]; c=mas[i+2][j-3]; d=mas[i+3][j-3];
- k4=(a-1)*(b-1)*(c+1)*(d+1) + (a-1)*(b-1)*c*d + (a-1)*b*(c+1)*d + (a-1)*b*c*(d+1); a=mas[i][j-4]; b=mas[i+1][j-4]; c=mas[i+2][j-4]; d=mas[i+3][j-4];
- k5=(a-1)*(b+1)*(c-1)*(d-1) + (a-1)*(b+1)*c*d + (a-1)*b*(c-1)*d + (a-1)*b*c*(d-1); a=mas[i][j-5]; b=mas[i+1][j-5]; c=mas[i+2][j-5]; d=mas[i+3][j-5];
- k6=(a-1)*(b+1)*(c-1)*(d+1) + (a-1)*(b+1)*c*d + (a-1)*b*(c-1)*d + (a-1)*b*c*(d+1); a=mas[i][j-6]; b=mas[i+1][j-6]; c=mas[i+2][j-6]; d=mas[i+3][j-6];
- k7=(a-1)*(b+1)*(c+1)*(d-1) + (a-1)*(b+1)*c*d + (a-1)*b*(c+1)*d + (a-1)*b*c*(d-1); a=mas[i][j-7]; b=mas[i+1][j-7]; c=mas[i+2][j-7]; d=mas[i+3][j-7];
- k8=(a-1)*(b+1)*(c+1)*(d+1) + (a-1)*(b+1)*c*d + (a-1)*b*(c+1)*d + (a-1)*b*c*(d+1); a=mas[i][j-8]; b=mas[i+1][j-8]; c=mas[i+2][j-8]; d=mas[i+3][j-8];
- l1=(a+1)*(b-1)*(c-1)*(d-1) + (a-1)*(b-1)*c*d + (a-1)*b*(c-1)*d + (a-1)*b*c*(d-1); a=mas[i][j-9]; b=mas[i+1][j-9]; c=mas[i+2][j-9]; d=mas[i+3][j-9];
- l2=(a+1)*(b-1)*(c-1)*(d+1) + (a-1)*(b-1)*c*d + (a-1)*b*(c-1)*d + (a-1)*b*c*(d+1); a=mas[i][j-10]; b=mas[i+1][j-10]; c=mas[i+2][j-10]; d=mas[i+3][j-10];
- l3=(a+1)*(b-1)*(c+1)*(d-1) + (a-1)*(b-1)*c*d + (a-1)*b*(c+1)*d + (a-1)*b*c*(d-1); a=mas[i][j-11]; b=mas[i+1][j-11]; c=mas[i+2][j-11]; d=mas[i+3][j-11];
- l4=(a+1)*(b-1)*(c+1)*(d+1) + (a-1)*(b-1)*c*d + (a-1)*b*(c+1)*d + (a-1)*b*c*(d+1); a=mas[i][j-12]; b=mas[i+1][j-12]; c=mas[i+2][j-12]; d=mas[i+3][j-12];
- l5=(a+1)*(b+1)*(c-1)*(d-1) + (a-1)*(b+1)*c*d + (a-1)*b*(c-1)*d + (a-1)*b*c*(d-1); a=mas[i][j-13]; b=mas[i+1][j-13]; c=mas[i+2][j-13]; d=mas[i+3][j-13];
- l6=(a+1)*(b+1)*(c-1)*(d+1) + (a-1)*(b+1)*c*d + (a-1)*b*(c-1)*d + (a-1)*b*c*(d+1); a=mas[i][j-14]; b=mas[i+1][j-14]; c=mas[i+2][j-14]; d=mas[i+3][j-14];
- l7=(a+1)*(b+1)*(c+1)*(d-1) + (a-1)*(b+1)*c*d + (a-1)*b*(c+1)*d + (a-1)*b*c*(d-1); a=mas[i][j-15]; b=mas[i+1][j-15]; c=mas[i+2][j-15]; d=mas[i+3][j-15];
- l8=(a+1)*(b+1)*(c+1)*(d+1) + (a-1)*(b+1)*c*d + (a-1)*b*(c+1)*d + (a-1)*b*c*(d+1);
- if(((k1-l1) >= 0)&&((k2 - l2 ) >= 0)&&((k3-l3) >= 0)&&((k4 - l4 ) >= 0)&&((k5-l5) >= 0)&&((k6 - l6 ) >= 0)&&((k7-l7) >= 0)&&((k8 - l8) >= 0))
- {return 1;} else {return 0;}
- }
- }
- int main()
- {
- int s;
- int f1[4][16];
- int f2[4][16];
- int f3[4][16];
- int i,j,n,m,k,p,c;
- n=4;
- m=16;
- int a[5][17];
- for(i=1;i<=n;i++)
- for(j=1;j<=m; j++)
- a[i][j]=0;
- for(j=1;j<=n;j++)
- {
- k=m/(pow(2,j));
- p=0;
- c=0;
- for(i=k+1;i<=m; i++)
- {
- if(p<k)
- {
- a[j][i]=1;
- p++;
- }
- else if(c<k-1)
- {
- a[j][i]=0;
- c++;
- }
- else
- {
- p=0;
- c=0;
- }
- }
- }
- for (j=0; j<4; j++){
- for (i=0; i<2; i++){
- f1[i][j] = a[i+3][j+1];}
- }
- for (j=0; j<8; j++){
- for (i=0; i<3; i++){
- f2[i][j] = a[i+2][j+1];}}
- for (j=0; j<16; j++){
- for (i=0; i<4; i++){
- f3[i][j] = a[i+1][j+1];}}
- s=1;
- cout <<"T0 T1 Tm Tl Ts"<<endl;
- if(To(0,0,0,0,s) == 1){
- cout<<" -"; }
- else {cout<<" +";}
- if(T1(1,1,1,1,s) == 1){
- cout<<" +"; }
- else {cout<<" -";}
- if(Tm(s,f1) == 1){
- cout<<" +"; }
- else {cout<<" -";}
- if(Tl(f1) == 1){
- cout<<" +"; }
- else {cout<<" -";}
- if(Ts(f1) == 1){
- cout<<" +"<<endl; s++;}
- else {cout<<" -"<<endl; s++;}
- if(To(0,0,0,0,s) == 1){
- cout<<" -"; }
- else {cout<<" +";}
- if(T1(1,1,1,1,s) == 1){
- cout<<" +"; }
- else {cout<<" -";}
- if(Tm(s,f2) == 1){
- cout<<" +"; }
- else {cout<<" -";}
- if(Tl(f2) == 1){
- cout<<" +"; }
- else {cout<<" -";}
- if(Ts(f2) == 1){
- cout<<" +"<<endl; s++;}
- else {cout<<" -"<<endl; s++;}
- if(To(0,0,0,0,s) == 1){
- cout<<" -"; }
- else {cout<<" +";}
- if(T1(1,1,1,1,s) == 1){
- cout<<" +"; }
- else {cout<<" -";}
- if(Tm(s,f3) == 1){
- cout<<" +"; }
- else {cout<<" -";}
- if(Tl(f3) == 1){
- cout<<" +"; }
- else {cout<<" -";}
- if(Ts(f3) == 1){
- cout<<" +"<<endl; }
- else {cout<<" -"<<endl; }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement