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. 2..net core 和.net framework 版本

    同一台机器上可以安装多个版本的.net core runtime.比如: 每个.net core项目都可以指定自己所用的版本,所以改变某个项目的target version不会影响到其他的.安装新的r ...

  2. 3_PHP表达式_2_变量

    以下为学习孔祥盛主编的<PHP编程基础与实例教程>(第二版)所做的笔记. PHP变量可分为自定义变量和预定义变量. 以下所谈到的变量均为自定义变量. 1.变量的基本概念 PHP的变量名遵循 ...

  3. iOS应用开发---返回到指定界面

    关于ios中 viewcontroller的跳转问题,其中有一种方式是采用navigationController pushViewController 的方法,比如我从主页面跳转到了一级页面,又从一 ...

  4. 【异常】Maxwell异常 Exception in thread "main" net.sf.jsqlparser.parser.TokenMgrError: Lexical error at line 1, column 596. Encountered: <EOF> after : ""

    1 详细异常 Exception in thread "main" net.sf.jsqlparser.parser.TokenMgrError: Lexical error at ...

  5. Python_逻辑运算符

    1.逻辑运算符

  6. Python高阶用法总结

    目录 1. lambda匿名函数 1.1 函数式编程 1.2 应用在闭包 2. 列表解析式 3. enumerate内建函数 4. 迭代器与生成器 4.1 迭代器 4.3 生成器 5. 装饰器 前言: ...

  7. Python 包文件安装

    https://pypi.tuna.tsinghua.edu.cn/simple/ 清华源 https://pypi.doubanio.com/simple/ 豆瓣源 pip install -i h ...

  8. 子div撑不开父div的几种解决办法:

    如何修正DIV float之后导致的外部容器不能撑开的问题   在写HTML代码的时候,发现在Firefox等符合W3C标准的浏览器中,如果有一个DIV作为外部容器,内部的DIV如果设置了float样 ...

  9. SpringBoot框架之通用mapper插件(tk.mybatis)

    一.Tkmybatis的好处 Tkmybatis是在mybatis框架的基础上提供了很多工具,让开发更加高效.这个插件里面封装好了我们需要用到的很多sql语句,不过这个插件是通过我们去调用它封装的各种 ...

  10. Idea中用来遍历list集合的快捷键

    使用Intellij idea时,想要快捷生成for循环代码块: itar 生成array for代码块 for (int i = 0; i < array.length; i++) { = a ...