站点图标 陌路寒暄

Time

Time

时间: 1ms        内存:128M

描述:

Digital clock use 4 digits to express time, each digit is described by 3*3 characters (including”|”,”_”and” “).now given the current time, please tell us how can it be expressed by the digital clock.

输入:

There are several test cases.

Each case contains 4 integers in a line, separated by space.

Proceed to the end of file.

输出:

For each test case, output the time expressed by the digital clock such as Sample Output.

示例输入:

1 2 5 6
2 3 4 2

示例输出:

    _  _  _ 
  | _||_ |_ 
  ||_  _||_|
 _  _     _ 
 _| _||_| _|
|_  _|  ||_ 

提示:

参考答案(内存最优[800]):

#include <stdio.h>



int t[10][3][3]=

{

	//0

	{

		{' ', '_', ' '},

		{'|', ' ', '|'},

		{'|', '_', '|'}

	},

	//1

	{

		{' ', ' ', ' '},

		{' ', ' ', '|'},

		{' ', ' ', '|'},

	},

	//2

	{

		{' ','_',' '},

		{' ','_','|'},

		{'|','_',' '},

	},

	//3

	{

		{' ','_',' '},

		{' ','_','|'},

		{' ','_','|'},

	},

	//4

	{

		{' ',' ',' '},

		{'|','_','|'},

		{' ',' ','|'},

	},

	//5

	{

		{' ','_',' '},

		{'|','_',' '},

		{' ','_','|'},

	},

	//6

	{

		{' ','_',' '},

		{'|','_',' '},

		{'|','_','|'},

	},

	//7

	{

		{' ','_',' '},

		{' ',' ','|'},

		{' ',' ','|'},

	},

	//8

	{

		{' ','_',' '},

		{'|','_','|'},

		{'|','_','|'},

	},

	//9

	{

		{' ','_',' '},

		{'|','_','|'},

		{' ','_','|'},

	},

};





int main()

{

	//freopen("in.in","r",stdin);

	//freopen("out.out","w",stdout);

	int a[4];

	int i,j,k;

	while(scanf("%d %d %d %d",&a[0], &a[1],&a[2],&a[3]) != EOF)

	{

		for(i=0; i<3; ++i)

		{

			for(j=0; j<4; ++j)

			{

				for(k=0;k<3; ++k)

				{

					printf("%c", t[a[j]][i][k]);

				}

			}

			printf("\n");

		}

	}

}

参考答案(时间最优[0]):

//1004
#include <iostream>
#include <string>
#include <map>
#include <cmath>
#include <stdio.h> 
#define N 1010
 
using namespace std;
 
int a, b, c;
int n;
string arr_b[N];
 
int main()
{
 while (scanf("%d %d %d", &a, &b, &c)==3)
 {
  map<string, int> hasha;
  for (int i = 0; i < a; i++)
  {
   string sa;
   cin >> sa;
   hasha[sa] = 1;
  }
 
  for (int i = 0; i < b; i++)
   cin >> arr_b[i];
 
  map<string, int> hashc;
  for (int i = 0; i < c; i++)
  {
   string sc;
   cin >> sc;
   hashc[sc] = 1;
  }
 
  int first = 1;
  for (int i = 0; i < b; i++)
  {
   if (hasha[arr_b[i]]==1 && hashc[arr_b[i]]==0)
   {
    if (!first)
     cout << ' ';
    else
     first = 0;
    cout << arr_b[i];
   }
  }
 
  if (!first)
   cout << endl;
  else
   cout << "No enemy spy" << endl;
 }
 
 return 0;
}
 

题目和答案均来自于互联网,仅供参考,如有问题请联系管理员修改或删除。

退出移动版