Java常用类、集合框架类1
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的更多相关文章
- Java基础之集合框架类及泛型简介
		Collection接口 Collection 通用的常见方法 add()添加一个元素,可以指定脚标 addAll()将一个collection放入 clear()清除 remove()删除元素,返回 ... 
- Java集合框架类
		java集合框架类图 Collection接口(List.Set.Queue.Stack): 
- 第八节:详细讲解Java中的异常处理情况与I/O流的介绍以及类集合框架
		前言 大家好,给大家带来详细讲解Java中的异常处理情况与I/O流的介绍以及类集合框架的概述,希望你们喜欢 JAVA 异常 try...catch...finally结构的使用方法 class Tes ... 
- Java常用的加密解密类(对称加密类)
		Java常用的加密解密类 原文转载至:http://blog.csdn.net/wyc_cs/article/details/8793198 原创 2013年04月12日 14:33:35 1704 ... 
- Java基础--说集合框架
		版权所有,转载注明出处. 1,Java中,集合是什么?为什么会出现? 根据数学的定义,集合是一个元素或多个元素的构成,即集合一个装有元素的容器. Java中已经有数组这一装有元素的容器,为什么还要新建 ... 
- 第51节:Java当中的集合框架Map
		简书作者:达叔小生 Java当中的集合框架Map 01 Map提供了三个集合视图: 键集 值集 键-值 映射集 public String getWeek(int num){ if(num<0 ... 
- Java中的集合框架-Collection(一)
		一,Collection接口 在日常的开发工作中,我们经常使用数组,但是数组是有很多的局限性的,比如:数组大小固定后不可修改,只能存储基本类型的值等等. 基于数组的这些局限性,Java框架就产生了用于 ... 
- Java中的集合框架-Collections和Arrays
		上一篇<Java中的集合框架-Map>把集合框架中的键值对容器Map中常用的知识记录了一下,本节记录一下集合框架的两个工具类Collections和Arrays 一,Collections ... 
- Java中的集合框架-Map
		前两篇<Java中的集合框架-Commection(一)>和<Java中的集合框架-Commection(二)>把集合框架中的Collection开发常用知识点作了一下记录,从 ... 
- Java中的集合框架-Collection(二)
		上一篇<Java中的集合框架-Collection(一)>把Java集合框架中的Collection与List及其常用实现类的功能大致记录了一下,本篇接着记录Collection的另一个子 ... 
随机推荐
- java 线程同步、死锁
			转载地址:速学堂 https://www.sxt.cn/Java_jQuery_in_action/eleven-thread-synchronization.html 什么是线程同步 同步问题的提 ... 
- Python之网格搜索与检查验证-5.2
			一.网格搜索,在我们不确定超参数的时候,需要通过不断验证超参数,来确定最优的参数值.这个过程就是在不断,搜索最优的参数值,这个过程也就称为网格搜索. 二.检查验证,将准备好的训练数据进行平均拆分,分为 ... 
- MySQL绿色版mysql-5.7.17-winx64简洁安装教程
			1.解压MySQL绿色版,复制my-default.ini,修改名称为my.ini 2. 以下为my.ini文件 # For advice on how to change settings plea ... 
- centos7上使用git clone出现问题
			centos 7 git clone时出现不支持协议版本的问题 unable to access 'https://github.com/baloonwj/TeamTalk.git/': Peer ... 
- sql 防注入(更新问题)
			一下这条语句虽然不会是数据表中的数据发生变化,但是会对数据库主从造成影响 update `article` where `article_id` = '40&n974742=v995656' ... 
- echarts3关系图:力引导布局, 固定某些节点
			在数组里设置 fixed: true,<a href='http://echarts.baidu.com/option.html#series-graph.data.fixed'>官方文档 ... 
- python火爆背后
			Python是一种非常好的编程语言,也是目前非常有前途的一门学科.有很多工作要做,而且薪水也很高,这已经成为每个人进入IT行业的首选.那么Python能做什么呢?为什么这么热? 那么Python能做什 ... 
- UI5-技术篇-Implementing Expand Entity/Entity Set
			转载:https://blogs.sap.com/2014/07/18/implementing-expand-entityentity-set/ Requirement Considering a ... 
- 【vue&ts开发】Vue 3.0前的 TypeScript 最佳入门实践
			1.使用官方脚手架构建 新的 VueCLI工具允许开发者 使用 TypeScript 集成环境 创建新项目. 只需运行 vue createmy-app. 然后,命令行会要求选择预设.使用箭头键选择 ... 
- vue父子组件传值例子
			<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ... 
