CSU 1395:timebomb (Analog)

Source: Internet
Author: User

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)

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.