A   时间日期格式转换(SDUT 2246)(SimpleDateFormat用法)

转换的df2里面时间是US,上面的df1可以是CHINA或者US。

package test;
import java.util.*;
import java.text.ParseException;
import java.text.SimpleDateFormat; public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n;
n = sc.nextInt();
sc.nextLine();
SimpleDateFormat df1 = new SimpleDateFormat("yyyy/MM/dd-HH:mm:ss",Locale.US);
SimpleDateFormat df2 = new SimpleDateFormat("MM/dd/yyyy-hh:mm:ssa",Locale.US);
String s;
while(n -- > 0) {
s = sc.nextLine();
try {
System.out.println(df2.format(df1.parse(s)).toLowerCase());
}catch(ParseException e) {
e.printStackTrace();
}
} }
}

B  小学数学 (SDUT 2445)    spilt和Integer.parseInt()用法。

import java.io.*;
import java.util.*;
import java.nio.file.*;
import java.io.File;
import java.io.IOException; import java.util.Scanner; public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int ans = 0,i;
while (sc.hasNext()) {
String s = sc.nextLine();
String[] a = s.split("\\+|\\-|\\=");
if (!a[2].equals("?")) {
int x1 = Integer.parseInt(a[0]);
int x2 = Integer.parseInt(a[1]);
int x3 = Integer.parseInt(a[2]);
for(i = 0; i < s.length(); i ++) if(s.charAt(i) == '+' || s.charAt(i) == '-')break;
if (s.charAt(i) == '+') {
if (x1 + x2 == x3)
ans++;
}
else {
if(x1 - x2 == x3) ans ++;
}
}
}
System.out.println(ans);
}
}

加密术 (SDUT 2787)

import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner (System.in);
String s,t;
while(sc.hasNext()) {
s = sc.next();
t = sc.next();
int num = 0;
int i,j = 0;
int f = 0;
for(i = 0; i < s.length(); i ++) {
for(; j < t.length(); j ++) {
if(s.charAt(i) == t.charAt(j)) {
num ++;
break;
}
if(i != s.length() - 1) {
if(j == t.length()) {
f = 1;
break;
}
}
}
if(f == 1) break;
}
if(num == s.length() && f == 0)
System.out.println("Yes");
else
System.out.println("No");
} }
}

救基友记2(SDUT 2192) replace用法

import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner (System.in);
String s;
int t;
t = sc.nextInt();
while(t-- > 0) {
s = sc.next();
String s1 = "cRazY";
String s2 = "CraZy";
String news1 = "CrAZy";
String news2 = "cRAzY";
s = s.replace(s1, news1);
s = s.replace(s2, news2);
System.out.println(s);
}
sc.close();
}
}

Eddy的难题(SDUT 2271)indexOf用法

import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner (System.in);
String s,t;
while(sc.hasNext()) {
s = sc.next();
t = sc.next();
s = s + s;
if(s.length() / 2 < t.length()) {
System.out.println("no");
}
else {
if(s.indexOf(t) != -1) {
System.out.println("yes");
}
else System.out.println("no");
}
}
}
}

Java常用类、集合框架类1的更多相关文章

  1. Java基础之集合框架类及泛型简介

    Collection接口 Collection 通用的常见方法 add()添加一个元素,可以指定脚标 addAll()将一个collection放入 clear()清除 remove()删除元素,返回 ...

  2. Java集合框架类

    java集合框架类图 Collection接口(List.Set.Queue.Stack):

  3. 第八节:详细讲解Java中的异常处理情况与I/O流的介绍以及类集合框架

    前言 大家好,给大家带来详细讲解Java中的异常处理情况与I/O流的介绍以及类集合框架的概述,希望你们喜欢 JAVA 异常 try...catch...finally结构的使用方法 class Tes ...

  4. Java常用的加密解密类(对称加密类)

    Java常用的加密解密类 原文转载至:http://blog.csdn.net/wyc_cs/article/details/8793198 原创 2013年04月12日 14:33:35 1704 ...

  5. Java基础--说集合框架

    版权所有,转载注明出处. 1,Java中,集合是什么?为什么会出现? 根据数学的定义,集合是一个元素或多个元素的构成,即集合一个装有元素的容器. Java中已经有数组这一装有元素的容器,为什么还要新建 ...

  6. 第51节:Java当中的集合框架Map

    简书作者:达叔小生 Java当中的集合框架Map 01 Map提供了三个集合视图: 键集 值集 键-值 映射集 public String getWeek(int num){ if(num<0 ...

  7. Java中的集合框架-Collection(一)

    一,Collection接口 在日常的开发工作中,我们经常使用数组,但是数组是有很多的局限性的,比如:数组大小固定后不可修改,只能存储基本类型的值等等. 基于数组的这些局限性,Java框架就产生了用于 ...

  8. Java中的集合框架-Collections和Arrays

    上一篇<Java中的集合框架-Map>把集合框架中的键值对容器Map中常用的知识记录了一下,本节记录一下集合框架的两个工具类Collections和Arrays 一,Collections ...

  9. Java中的集合框架-Map

    前两篇<Java中的集合框架-Commection(一)>和<Java中的集合框架-Commection(二)>把集合框架中的Collection开发常用知识点作了一下记录,从 ...

  10. Java中的集合框架-Collection(二)

    上一篇<Java中的集合框架-Collection(一)>把Java集合框架中的Collection与List及其常用实现类的功能大致记录了一下,本篇接着记录Collection的另一个子 ...

随机推荐

  1. C#正则表达式根据分组命名取值

    string[] regexList = new string[] { @"^(?<TickerPart1>[0-9A-Z])[ 0_]?(?<TickerPart2> ...

  2. iOS - Scenekit3D引擎初探之 - 给材质贴图

    今天简单说一下 SceneKit 给材质贴图. 1,最简单的一种方法,直接打开dae 或者 scn 文件直接设置  如上图,这个dae 文件中只有一个几何体,几何体中只有一个材质球,然后设置材质球的d ...

  3. angular中控制器之间传递参数的方式

    在angular中,每个controller(控制器)都会有自己的$scope,通过为这个对象添加属性赋值,就可以将数据传递给模板进行渲染,每个$scope只会在自己控制器内起作用,而有时候需要用到其 ...

  4. linux操作常用命令

    此篇文章是根据自己经常使用的命令进行记录备忘,不断更新 防火墙(centos7) 永久开放某个端口号: firewall-cmd --zone=public --add-port=8080/tcp - ...

  5. 面试常考HTTP协议知识点

    协议简介 1. 应用层协议, 一般以TCP为基础,数据收发通过TCP实现: 2. 一次性连接.服务器与客户端的每次连接只处理一个请求,下次请求重新建立连接: 3. 无状态协议.服务器不保留与客户交易时 ...

  6. Servlet快速入门:第一个Servlet程序

    Servlet是整个JavaWeb开发的核心,同时也是一套规范,即公共接口.用于处理客户端发来的请求并作出响应.通常情况下我们会发送不同的请求并交由不同的处理程序来处理,例如处理用户信息和处理订单信息 ...

  7. OpenStack中虚拟机获取不到IP地址的解决方法

    OpenStack源码交流群: 538850354 系统环境: centos6.5 + icehouse多节点部署 问题描述: 使用测试镜像cirros,虚拟机实例可以正常启动,但是不能从IP池中获取 ...

  8. evpp http response_http_code_

    response_http_code_  909 例子代码   evpp  代码内例子 注释 可以读一下

  9. P1168 中位数[堆 优先队列]

    题目描述 给出一个长度为NNN的非负整数序列AiA_iAi​,对于所有1≤k≤(N+1)/21 ≤ k ≤ (N + 1) / 21≤k≤(N+1)/2,输出A1,A3,…,A2k−1A_1, A_3 ...

  10. idea中tomcat的On Upate Action 与 On Frame Deactivation配置

    On Upate Action 与 On Frame Deactivation  这两个选项的设置,依赖于项目的部署方式 是war包 还是 exploded , 只讲exploded模式下的设置,因为 ...