Java练习 SDUT-2272_Time
Time
Time Limit: 1000 ms Memory Limit: 65536 KiB
Problem Description
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.
Input
There are several test cases.
Each case contains 4 integers in a line, separated by space.
Proceed to the end of file.
Output
For each test case, output the time expressed by the digital clock such as Sample Output.
Sample Input
1 2 5 6
2 3 4 2
Sample Output

一道绘图题,这种题一直是弱项,头铁强制画了出来,浪费了挺多时间。而且整个人都狂燥了。
结果看到这份代码
- z_xindong的代码
瞬间清醒了,其实用三维数组存一下就可以了。(String开二维就好)
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner cin=new Scanner(System.in);
String[][] time=new String[][]{
{" _ "," "," _ "," _ "," "," _ "," _ "," _ "," _ "," _ "},
{"| |"," |"," _|"," _|","|_|","|_ ","|_ "," |","|_|","|_|"},
{"|_|"," |","|_ "," _|"," |"," _|","|_|"," |","|_|"," _|"}};
while(cin.hasNext()){
int[] a=new int[4];
for(int i=0;i<4;i++){
a[i]=cin.nextInt();
}
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 4; j++) {
System.out.print(time[i][a[j]]);
}
System.out.println();
}
}
}
}
Java练习 SDUT-2272_Time的更多相关文章
- Java练习 SDUT - 2669_2-2 Time类的定义
2-2 Time类的定义 Time Limit: 1000 ms Memory Limit: 65536 KiB Problem Description 通过本题目的练习可以掌握类与对象的定义: 设计 ...
- Spark案例分析
一.需求:计算网页访问量前三名 import org.apache.spark.rdd.RDD import org.apache.spark.{SparkConf, SparkContext} /* ...
- Java 泛型快速排序 以sdut 1196为例
oj链接:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=1196 Java中,Arrays.so ...
- SDUT中大数实现的题目,持续更新(JAVA实现)
SDUT2525:A-B (模板题) import java.util.Scanner; import java.math.*; public class Main { public static v ...
- Java 【 ArrayList应用 】 (SDUT 4069 C~K的班级)
Java 里面的所有的东西 数组.字符数组.等等,都要 new 新申请. C~K的班级 代码: package test; import java.util.*; public class Main ...
- 山东理工大学SDUT - ACM OJ 题: Python代码 及分析
Python基础语法学习完成,先刷基础题100道巩固 ,附 题目.代码.知识分析 题目:http://acm.sdut.edu.cn/onlinejudge2/index.php/Home/Index ...
- Java String 中的一些函数与正则的结合使用
首先正则表达式在处理字符串问题时,真的非常强大. 正则可以帮助我们处理字符串的: 匹配, 选择, 编辑, 验证等问题. 正则中"\\"表示插入一个"\" 这里仅 ...
- Java 中的 SimpleDateFormat 【 parse 和 format 】【转换时间格式】
在 Java 里面有很多特别方便的函数(尽管术语可能不这么说)可以供我们使用,让一些本来要写好长好多的代码的事情变得仅仅几行就解决了. 在 SimpleDateFormat 中,有以下特定的规则: G ...
- Java面向对象6 (AA - AE)
整理音乐(SDUT 2053) import java.util.*; public class Main { public static void main(String[] args) { Sca ...
- Java常用类、集合框架类1
A 时间日期格式转换(SDUT 2246)(SimpleDateFormat用法) 转换的df2里面时间是US,上面的df1可以是CHINA或者US. package test; import j ...
随机推荐
- Jquery 判断值是否存在于数组之内
var strArray=str.split(","); var fixed_init=function(v){ if($.inArray(v,strArray)==-1){ // ...
- Tomcat中startup.bat启动无效
error: Linux下启动和关闭tomcat报错,如下图所示: 而在windows下用cmd启动startup.bat也会报如上的错误: Neither the JAVA_HOME nor the ...
- JSP/FTL 中获取param、request、session、application中的值
Java JSP(EL表达式) FTL ① <% page.getAttribute("attr") %> ${pageScope .attr} - ② reque ...
- 使用Docker 安装Elasticsearch、Elasticsearch-head、IK分词器 和使用
原文:使用Docker 安装Elasticsearch.Elasticsearch-head.IK分词器 和使用 Elasticsearch的安装 一.elasticsearch的安装 1.镜像拉取 ...
- ifconfig配置IP地址和子网掩码
ifconfig eth0 192.168.2.10 ifconfig eth0 192.168.2.10 netmask 255.255.255.0
- JSP-request(httpServletRequest)
HttpServletRequest 1 HttpServletRequest概述 2 request运行流程 3 通过抓包工具抓的http请求 4 请求行信息的相关方法 //1.获得请求方式 Str ...
- Hdu 1498 二分匹配
50 years, 50 colors Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...
- Android消息机制使用注意事项,防止泄漏
在Android的线程通信当中,使用频率最多的就是Android的消息处理机制(Handler.send().View.post().Asynctask.excute()等等都使用到了消息处理机制). ...
- js自定义滚动条
今天听到别人说自定义滚动条,所以就在吃饭的时间写了个 html部分 <div class="out" id="out"> <div class ...
- Duplicate a whole line in Vim
yy or Y to copy the line or dd to delete (cutting) the line then p to paste the copied or deleted te ...