Usaco 1.2.2 Transformations

Source: Internet
Author: User

Usaco 1.2.2 Transformations

Question: a matrix and a 7-center transformation method are provided to determine which transformation method can be used to obtain the target matrix. Number of the feasible transformation method with the smallest output number.

It's mainly about code capabilities ~

Details + code:

 

/* ID: 15257142 LANG: C task: Transform */# include <stdio. h> int N;/* Global ease of use. */Int cmp (char d [15] [15], char C [15] [15]) {int F, I, j; F = 1; for (I = 0; I <= n-1; I ++) {for (j = 0; j <= n-1; j ++) {If (d [I] [J]! = C [I] [J]) {f = 0; break ;}}return F ;}int trans1 (char a [15] [15], char d [15] [15]) {int I, j; for (I = 0; I <= n-1; I ++) {for (j = 0; j <= n-1; j ++) {d [I] [J] = A [n-1-j] [I] ;}} return 0 ;} int trans2 (char a [15] [15], char d [15] [15]) {int I, j; for (I = 0; I <= n-1; I ++) {for (j = 0; j <= n-1; j ++) {d [I] [J] = A [n-1-i] [n-1-j];} return 0;} int trans3 (char a [15] [15], char d [15] [15]) {int I, j; for (I = 0; I <= n-1; I ++) {for (j = 0; j <= n-1; j ++) {d [I] [J] = [J] [n-1-i];} return 0;} int trans4 (char a [15] [15], char d [15] [15]) {/* read question, meaning horizontal flip! */INT I, j; for (I = 0; I <= n-1; I ++) {for (j = 0; j <= n-1; j ++) {d [I] [J] = A [I] [n-1-j];} return 0;} int trans51 (char a [15] [15], char d [15] [15], char E [15] [15]) {int I, j; for (I = 0; I <= n-1; I ++) {for (j = 0; j <= n-1; j ++) {d [I] [J] = A [I] [n-1-j] ;}} for (I = 0; I <= n-1; I ++) {for (j = 0; j <= n-1; j ++) {e [I] [J] = d [n-1-j] [I];} return 0;} int trans52 (char a [15] [15], char d [15] [15], char E [15] [15]) {int I, j; for (I = 0; I <= n-1; I ++) {for (j = 0; j <= N-1; j ++) {d [I] [J] = A [I] [n-1-j] ;}for (I = 0; I <= n-1; I ++) {for (j = 0; j <= n-1; j ++) {e [I] [J] = d [n-1-i] [n-1-j] ;}} return 0 ;} int trans53 (char a [15] [15], char d [15] [15], char E [15] [15]) {int I, J; for (I = 0; I <= n-1; I ++) {for (j = 0; j <= n-1; j ++) {d [I] [J] = A [I] [n-1-j] ;}for (I = 0; I <= n-1; I ++) {for (j = 0; j <= n-1; j ++) {e [I] [J] = d [J] [n-1-i] ;}} return 0 ;} int main () {freopen ("transform. in "," r ", stdin); freopen (" transform. out "," W", Stdout); char a [15] [15], d [15] [15], E [15] [15], C [15] [15]; int I, j, k; scanf ("% d", & N); getchar ();/* why can't you remember it! */For (I = 0; I <= n-1; I ++) {for (j = 0; j <= n-1; j ++) scanf ("% C ", & A [I] [J]); getchar ();/*! */} For (I = 0; I <= n-1; I ++) {for (j = 0; j <= n-1; j ++) scanf ("% C", & C [I] [J]); getchar ();} k = 1; if (k = 1) {trans1 (, d); If (CMP (D, C) = 1) {printf ("1 \ n"); k = 0 ;}} if (k = 1) {trans2 (a, d); If (CMP (D, C) = 1) {printf ("2 \ n"); k = 0 ;}} if (k = 1) {trans3 (a, d); If (CMP (D, C) = 1) {printf ("3 \ n "); k = 0 ;}} if (k = 1) {trans4 (a, d); If (CMP (D, C) = 1) {printf ("4 \ n"); k = 0 ;}} if (k = 1) {trans51 (A, D, E); If (CMP (E, c) = 1) {printf ("5 \ n"); k = 0 ;}} if (k = 1) {trans52 (A, D, E ); if (CMP (E, C) = 1) {printf ("5 \ n"); k = 0 ;}} if (k = 1) {trans53 (, d, e); If (CMP (E, C) = 1) {printf ("5 \ n"); k = 0 ;}} if (k = 1) {If (CMP (a, c) = 1) {printf ("6 \ n"); k = 0 ;}} if (k = 1) printf ("7 \ n"); fclose (stdin); fclose (stdout); Return 0 ;}

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.