From 63d7a27317a7175da90d57c7c85a49b3650064d6 Mon Sep 17 00:00:00 2001 From: p56isruwj <3475735425@qq.com> Date: Sun, 29 Oct 2023 10:05:02 +0800 Subject: [PATCH] ADD file via upload --- sdjz group30.cpp | 149 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 sdjz group30.cpp diff --git a/sdjz group30.cpp b/sdjz group30.cpp new file mode 100644 index 0000000..6db6f4a --- /dev/null +++ b/sdjz group30.cpp @@ -0,0 +1,149 @@ +#include +#include +#include +int a[10][10]; +int e,f,g; +void input() +{ + for(int i=1;i<10;i++) + for(int j=1;j<10;j++) + scanf("%d",a[i][j]); +} +void random() +{ + for(int i=1;i<10;i++) + for(int j=1;j<10;j++) + a[i][j]=rand()%10; +} +void format(int s[][10]) +{ + printf("-------------------------\n"); + for(int i=1;i<10;i++) + { + printf("| "); + for(int j=1;j<10;j++) + { + + printf("%d ",s[i][j]); + if(j%3==0) printf("| "); + } + printf("\n"); + if(i%3==0) printf("-------------------------\n"); + } +} +bool ok(int x,int y,int s[][10]) +{ + int b=s[x][y]; + for(int i=1;i<=9;i++) + { + if(i==x) continue; + if(s[i][y]==b) + { + e=0;f=y;g=b; + return false; + } + } + for(int j=1;j<=9;j++) + { + if(j==y) continue; + if(s[x][j]==b) + { + e=1;f=x;g=b; + return false; + } + } + x=(x-1)/3*3; + y=(y-1)/3*3; + int block; + if(x+1==1) + { + if(y+1==1) block=1; + else if(y+1==4) block=2; + else if(y+1==7) block=3; + } + else if(x+1==4) + { + if(y+1==1) block=4; + else if(y+1==4) block=5; + else if(y+1==7) block=6; + } + else if(x+1==7) + { + if(y+1==1) block=7; + else if(y+1==4) block=8; + else if(y+1==7) block=9; + } + for(int i=x+1;i