Test instructions: Give some numbers if they can be divisible by 6 output beer!! Otherwise output boom!!
Idea: Save 0 to 9 with a three-dimensional array
Violence out of every number of values
Find the results
(This is a bit of a hole in the 1 number may not exist 2 number of uncertainties)
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm>using namespace Std;char num[10][10][10]={{"* * *", "* *", "* *", "* *", "* *"}, {"*", "*", "*", "*", "*"}, {"* * *", "*", "* *", "*", " ***"}, {"***"," *","***"," *","***"}, {"* *","* *","***"," *"," *"}, {"***","* ","***"," *","***"}, {"***","* " ,"***","* *","***"}, {"***"," *"," *"," *"," *"}, {"***","* *","***","* *","***"}, {"***","* *","***"," *","***"}} ; Char Mat[100][100];int main () {int i,j,k; int l,m,n; int sum,res; memset (Mat,0,sizeof (MAT)); while (gets (mat[0])) {Sum=0;res=1; for (i=1;i<=4;i++) {gets (mat[i]); } int Len=strlen (mat[0]); for (i=0;i<len;i+=4) {to (j=0;j<10;j++) {/*if (j==6) {for (k=0;k<5;k++) {for (l=0;l<3;l++) {printf ("%c", Num[j][k][l]); } printf ("\ n"); }}*/for (k=0;k<5;k++) { for (l=0;l<3;l++) {if (num[j][k][l]== ' * ') {if (Mat[k][l+i]!=num[j][k][l] ) {break;} } else if (num[j][k][l]== ') {if (mat[k][l+i]== ' * ') break; }} if (l!=3) {break;} }//if (j==6) printf ("%d....\n", K); if (k==5) {break; }}//printf ("%d...\n", j); if (j<10) {sum=sum*10+j; } else {res=0; Break }}//printf ("%d%d\n", res,sum); if (res==0| | sum%6!=0) printf ("boom!! \ n "); else printf ("beer!! \ n "); memset (Mat,0,sizeof (MAT)); } return 0;}
CSU 1395:timebomb (Analog)