tag: OS Io for Re C Code
# Include <stdio. h> # include <string. h >#include <string >#include <iostream> # include <algorithm> using namespace STD; int H [20] [20]; int V [20] [20]; int size _ [20]; int n, m; int flag; void judge (int x, int y) // This is the key part of the code to determine whether it can constitute square; {int a1 = N-X; int a2 = N-y; int AA = min (a1, a2); For (INT I = 0; I <AA; I ++) {If (H [x] [Y + I] & V [x + I] [Y]) {Int J; For (j = 0; j <= I; j ++) {If (! (H [x + I + 1] [Y + J]) |! (V [x + J] [Y + I + 1]) {break;} If (j = I) {flag = 1; size _ [I] ++ ;}}} else break ;}} int main () {int Kase = 0; while (scanf ("% d", & N )! = EOF) {scanf ("% d", & M); Kase ++; flag = 0; memset (size _, 0, sizeof (size _)); memset (H, 0, sizeof (h); memset (v, 0, sizeof (v); int a1, a2; string s; For (INT I = 0; I <m; I ++) {CIN> S> A1> A2; If (S = "H ") {H [a1] [a2] = 1;} If (S = "v") {v [a2] [a1] = 1 ;}} for (INT I = 1; I <= N; I ++) {for (Int J = 1; j <= N; j ++) {If (H [I] [J] & V [I] [J]) {judge (I, j) ;}} if (Kase! = 1) printf ("\ n **********************************\ N "); printf ("problem # % d \ n", Kase); If (flag = 1) {for (INT I = 0; I <20; I ++) {If (size _ [I]! = 0) {printf ("% d square (s) of size % d \ n", size _ [I], I + 1 );}}} else printf ("no completed squares can be found. \ n ") ;}return 0 ;}