zoukankan      html  css  js  c++  java
  • 2017 Multi-University Training Contest

    链接:http://acm.hdu.edu.cn/contests/contest_showproblem.php?pid=1011&cid=762

    题意:给定一个X和.组成的图案,输出图案里的数字。

    分析:- - 一开始没看懂题目,没发现给的图里就是数字了。。打个0到9的表,直接读完判一下,就水过去了。。

     1 #include<iostream>
     2 #include<cstdio>
     3 #include<cstring>
     4 using namespace std;
     5 char p[7][25];
     6 char num[10][30]={
     7     ".XX.X..XX..X....X..XX..X.XX.",
     8     ".......X...X.......X...X....",
     9     ".XX....X...X.XX.X...X....XX.",
    10     ".XX....X...X.XX....X...X.XX.",
    11     "....X..XX..X.XX....X...X....",
    12     ".XX.X...X....XX....X...X.XX.",
    13     ".XX.X...X....XX.X..XX..X.XX.",
    14     ".XX....X...X.......X...X....",
    15     ".XX.X..XX..X.XX.X..XX..X.XX.",
    16     ".XX.X..XX..X.XX....X...X.XX."
    17 };
    18 int Check(char s[30]){
    19     for(int i=0;i<10;i++){
    20         if(strcmp(s,num[i])==0)return i;
    21     }
    22     return -1;
    23 }
    24 int main(){
    25     int kase;
    26     char s[40];
    27     int ans[4];
    28     scanf("%d",&kase);
    29     while(kase--){
    30         for(int i=0;i<7;i++)
    31             scanf("%s",p[i]);
    32         s[0]='';
    33         for(int i=0;i<7;i++){
    34             strcat(s,p[i]);
    35             s[4*i+4]='';
    36         }
    37         ans[0]=Check(s);
    38         s[0]='';
    39         for(int i=0;i<7;i++){
    40             strcat(s,p[i]+5);
    41             s[4*i+4]='';
    42         }
    43         ans[1]=Check(s);
    44         s[0]='';
    45         for(int i=0;i<7;i++){
    46             strcat(s,p[i]+12);
    47             s[4*i+4]='';
    48         }
    49         ans[2]=Check(s);
    50         s[0]='';
    51         for(int i=0;i<7;i++){
    52             strcat(s,p[i]+17);
    53             s[4*i+4]='';
    54         }
    55         ans[3]=Check(s);
    56         printf("%d%d:%d%d
    ",ans[0],ans[1],ans[2],ans[3]);
    57     }
    58     return 0;
    59 }
  • 相关阅读:
    【leetcode】525. Contiguous Array
    【leetcode】827. Making A Large Island
    【leetcode】540. Single Element in a Sorted Array
    【leetcode】45. Jump Game II
    2017.11.2 Talk to customers for an hour
    New Concept English three (29)
    New Concept English three (28)
    2017.10.31 Enginer+position+statement
    New Concept English three (27)
    2017.10.30 Epicor -ERP
  • 原文地址:https://www.cnblogs.com/7391-KID/p/7282468.html
Copyright © 2011-2022 走看看