国庆休息写点东西,扫描文件和jar的工具类,汉化后的CoffeeScript可以这样写fibon,汉化后的CoffeeScript可以这样写fibon,汉字表示的数字转换成阿拉伯数字
汉字验证码和算式验证码,杭电利息计算+第几天+Elevator+素数判定+熊猫阿波的获取main函数入参的两种方式
[文件] Diamond.java
package com.my;
import java.awt.Button;
import java.util.Set;
// 每一个小方块类
//Python实现的哈夫曼编码
public class Diamond extends Button {
private Diamond[] diamonds;
//python实现单链表
// 该小方块周围的八个方向上的小方块
private Diamond east;
private Diamond north;
private Diamond northEast;
private Diamond northWest;
private Diamond south;
private Diamond southEast;
private Diamond southWest;
private Diamond west;
//Python抓取知乎日报的内容
private boolean isBomb;// 是否是雷
private boolean isChange;// 又没有被翻过
private int no;// 产生的方块的编号
// 持有所有小方块的引用,方便进行操作
public Diamond(Diamond[] diamonds) {
this.diamonds = diamonds;
}
// 按键时方块发生改变
public boolean change() {
this.isChange = true;// 说明已经翻过了
if(isBomb) {// 触雷
//this.setBackground(Color.red);
return true;
} else {// 不是雷,就显示周围雷的数目
//this.setLabel(this.getNearBombNo() + "");
this.setLabel(this.getNearBombNo() + "");
//if(this.getNearBombNo() == 0) {
// this.moveon();
//}
return false;
}
}
// 获得该小方块周围雷的数量
public int getNearBombNo() {
int no = 0;
if(this.northWest != null && this.northWest.isBomb) no++;
if(this.north != null && this.north.isBomb) no++;
if(this.northEast != null && this.northEast.isBomb) no++;
if(this.east != null && this.east.isBomb) no++;
if(this.southEast != null && this.southEast.isBomb) no++;
if(this.south != null && this.south.isBomb) no++;
if(this.southWest != null && this.southWest.isBomb) no++;
if(this.west != null && this.west.isBomb) no++;
return no;
}
// 获得该小方块周围的小方块
public Diamond getNearDimaond(int i) {
int index = -1;
switch (i) {
case 1:// 1表示西北,2,表示北,以此类推
index = no - 10;
if(index < 1 || no == 19 || no == 28 || no == 37 || no == 46 || no == 55 || no == 64 || no == 73) {
return null;
} else {
return diamonds[index];
}
case 2:
index = no - 9;
if(index < 1) {
return null;
} else {
return diamonds[index];
}
case 3:
index = no - 8;
if(index < 1 || no == 9 || no == 18 || no == 27 || no == 36 || no == 45 || no == 54 || no == 63 || no == 72) {
return null;
} else {
return diamonds[index];
}
case 4:
index = no + 1;
if(no == 9 || no == 18 || no == 27 || no == 36 || no == 45 || no == 54 || no == 63 || no == 72 || no == 81) {
return null;
} else {
return diamonds[index];
}
case 5:
index = no + 10;
if(index >= 81 ||no == 9 || no == 18 || no == 27 || no == 36 || no == 45 || no == 54 || no == 63 || no == 72 || no == 81) {
return null;
} else {
return diamonds[index];
}
case 6:
index = no + 9;
if(index > 81) {
return null;
} else {
return diamonds[index];
}
case 7:
index = no + 8;
if(index >= 81 || no==1 || no == 10 || no == 19 || no == 28 || no == 37 || no == 46 || no == 55 || no == 64 || no == 73) {
return null;
} else {
return diamonds[index];
}
case 8:
index = no - 1;
if(no==1 || no==10 || no == 19 || no == 28 || no == 37 || no == 46 || no == 55 || no == 64 || no == 73) {
return null;
} else {
return diamonds[index];
}
}
return null;
}
// 递归,set是用来装已经翻过的小方块的,不然会死循环,为什么用set,因为set 是不重复的
public void moveon(Set
set.add(this);// 先把自己加上
if(this.getNorthWest() != null && this.getNorthWest().isBomb == false) {
this.getNorthWest().change();
if(this.getNorthWest().getNearBombNo() == 0) {
if(set.contains(this.getNorthWest()) == false) this.getNorthWest().moveon(set);
}
set.add(this.getNorthWest());
}
if(this.getNorth() != null && this.getNorth().isBomb == false) { this.getNorth().change();
if(this.getNorth().getNearBombNo() == 0) {
if(set.contains(this.getNorth()) == false)
this.getNorth().moveon(set);
}
set.add(this.getNorth());
}
if(this.getNorthEast() != null && this.getNorthEast().isBomb == false) {
this.getNorthEast().change();
if(this.getNorthEast().getNearBombNo() == 0) {
if(set.contains(this.getNorthEast()) == false) this.getNorthEast().moveon(set);
}
set.add(this.getNorthEast());
}
if(this.getEast() != null && this.getEast().isBomb == false) { this.getEast().change();
if(this.getEast().getNearBombNo() == 0) {
if(set.contains(this.getEast()) == false)
this.getEast().moveon(set);
}
set.add(this.getEast());
}
if(this.getSouthEast() != null && this.getSouthEast().isBomb == false) {
this.getSouthEast().change();
if(this.getSouthEast().getNearBombNo() == 0) {
if(set.contains(this.getSouthEast()) == false) this.getSouthEast().moveon(set);
}
set.add(this.getSouthEast());
}
if(this.getSouth() != null && this.getSouth().isBomb == false) { this.getSouth().change();
if(this.getSouth().getNearBombNo() == 0) {
if(set.contains(this.getSouth()) == false)
this.getSouth().moveon(set);
}
set.add(this.getSouth());
}
if(this.getSouthWest() != null && this.getSouthWest().isBomb == false) {
this.getSouthWest().change();
if(this.getSouthWest().getNearBombNo() == 0) {
if(set.contains(this.getSouthWest()) == false) this.getSouthWest().moveon(set);
}
set.add(this.getSouthWest());
}
if(this.getWest() != null && this.getWest().isBomb == false) { this.getWest().change();
if(this.getWest().getNearBombNo() == 0) {
if(set.contains(this.getWest()) == false)
this.getWest().moveon(set);
}
set.add(this.getWest()); }
}
/*public Diamond[] getDiamonds() {
return diamonds;
}*/
public Diamond getEast() {
return east;
}
public int getNo() {
return no;
}
public Diamond getNorth() {
return north;
}
public Diamond getNorthEast() {
return northEast;
}
public Diamond getNorthWest() {
return northWest;
}
public Diamond getSouth() {
return south;
}
public Diamond getSouthEast() {
return southEast;
}
public Diamond getSouthWest() {
return southWest;
}
public Diamond getWest() {
return west;
}
public boolean isBomb() {
return isBomb;
}
public boolean isChange() {
return isChange;
}
public void setBomb(boolean isBomb) {
this.isBomb = isBomb;
}
public void setChange(boolean isChange) {
this.isChange = isChange;
}
public void setDiamonds(Diamond[] diamonds) { this.diamonds = diamonds;
}
public void setEast(Diamond east) {
this.east = east;
}
public void setNo(int no) {
this.no = no;
}
public void setNorth(Diamond north) {
this.north = north;
}
public void setNorthEast(Diamond northEast) { this.northEast = northEast;
}
public void setNorthWest(Diamond northWest) { this.northWest = northWest;
}
public void setSouth(Diamond south) {
this.south = south;
}
public void setSouthEast(Diamond southEast) {
this.southEast = southEast;
}
public void setSouthWest(Diamond southWest) {
this.southWest = southWest;
}
public void setWest(Diamond west) {
this.west = west;
}
}
.[文件] MainFrame.java ~ 19KB 下载(1851) [代码] [PHP]代码
/**
* 虚基类
*/
abstract class T{
abstract function show();
}
/**
* 子类
*/
class T1 extends T {
public function show(){
echo "T1 from abstract class!
";
}
public function show1(){
echo "T1 not from abstract class!
"; }
}
/**
* 子类
*/
class T2 extends T {
public function show(){
echo "T2 from abstract class!
";
public function show1(){
echo "T2 not from abstract class!
";
}
}
class T3 {
public function show(){
echo "in T3!
";
}
public function show1(){
echo "in T3!
";
}
}
$t1 = new T1();
$t2 = new T2();
$t3 = new T3();
show($t1);
show($t2);
//报错,$t3不是T,所以被show函数调用的时候,会报类型不对的错误//show($t3);
function show( T $t ){//注意参数的类型
$t->show();
$t->show1();
}
?>
[文件] gif4j_pro_2.0_0328.jar ~ 59KB 下载(430)
文件不存在或者代码语言不存在
[代码] HTML
#*
* 输出日历
* $__year 年 $__month 月 $__dow day of week
*#
#macro(draw_calendar $__year $__month $__dow)
#if($__year >1900&& $__month>0&& $__month <13)
$__year年$__month月 | ||||||
日 | 一 | 二 | 三 | 四 | 五 | 六 |
$__i |
#end
#end
[代码] [Java]代码
package cn.jd3g.utils;
import https://www.doczj.com/doc/7e1133346.html,ng.ref.SoftReference;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map.Entry;
import android.graphics.Bitmap;
import android.os.Handler;
import android.util.Log;
import android.widget.ImageView;
/**
* 利用多线程异步加载图片并更新视图
*
* @author xfzhang
*
*/
public final class AsynImageLoader {
private LoaderThread thread;// 加载图片并发消息通知更新界面的线程
private HashMap
private Handler handler;// 界面Activity的Handler对象
public AsynImageLoader(Handler handler) {
imageCache = new HashMap
this.handler = handler;
}
/**
* 加载图片前显示到指定的ImageView中,图片的保存在视图对象的Tag中
* https://www.doczj.com/doc/7e1133346.html,
* @param imageView
* 要显示图片的视图
* @param defaultBitmap
* 加载需要显示的提示正在加载的默认图片对象
*/
public void loadBitmap(ImageView imageView, Bitmap defaultBitmap) {
// 图片所对应的,这个值在加载图片过程中很可能会被改变
String = (String) imageView.getTag();
if (imageCache.containsKey()) {// 判断缓存中是否有
SoftReference
if (bitmap != null) {// 如果图片对象不为空,则可挂接更新视图,并返回
imageView.setImageBitmap(bitmap);
return;
} else {// 如果为空,需要将其从缓存中删除(其bitmap对象已被回收释放,需要重新加载)
Log.e("TAG", "cache bitmap is null");
imageCache.remove();
}
}
imageView.setImageBitmap(defaultBitmap);// 先显示一个提示正在加载的图片
if (thread == null) {// 加载线程不存在,线程还未启动,需要新建线程并启动
thread = new LoaderThread(imageView, );
thread.start();
} else {// 如果存在,就调用线程对象去加载
thread.load(imageView, );
}
}
/**
* 释放缓存中所有的Bitmap对象,并将缓存清空
*/
public void releaseBitmapCache() {
if (imageCache != null) {
for (Entry
Bitmap bitmap = entry.getValue().get();
if (bitmap != null) {
bitmap.recycle();// 释放bitmap对象
}
}
imageCache.clear();
}
}
/**
* 加载图片并显示的线程
*/
private class LoaderThread extends Thread {
LinkedHashMap
private boolean mIsWait;// 标识是线程是否处于等待状态
public LoaderThread(ImageView imageView, String ) {
mTaskMap = new LinkedHashMap
mTaskMap.put(, imageView);
}
/**
* 处理某个视图的更新显示
*
* @param imageView
*/
public void load(ImageView imageView, String ) {
mTaskMap.remove(imageView);// 任务链中可能有,得先删除 mTaskMap.put(, imageView);// 将其添加到任务中
if (mIsWait) {// 如果线程此时处于等待得唤醒线程去处理任务队列中待处理的任务
synchronized (this) {// 调用对象的notify()时必须同步
this.notify();
}
}
}
https://www.doczj.com/doc/7e1133346.html, 秦皇岛同城购侭侰侮
@Override
public void run() {
while (mTaskMap.size() > 0) {// 当队列中有数据时线程就要一直运行,一旦进入就要保证其不会跳出循环
mIsWait = false;
final String =
mTaskMap.keySet().iterator().next();
final ImageView imageView = mTaskMap.remove(); if (imageView.getTag() == ) {// 判断视图有没有复用(一旦ImageView被复用,其tag值就会修改变)
final Bitmap bitmap =
MyConnection.getBitmapByUrl();// 此方法应该是从网络或sd卡中加载
try {
Thread.sleep(1000);// 模拟网络加载数据时间
} catch (InterruptedException e1) {
e1.printStackTrace();
}
// 将加载的图片放入缓存map中
imageCache.put(, new
SoftReference
if ( == imageView.getTag()) {// 再次判断视图有没有复用
handler.post(new Runnable() {// 通过消息机制在主线程中更新UI
@Override
public void run() {
imageView.setImageBitmap(bitmap);
}
});
}
}
if (mTaskMap.isEmpty()) {// 当任务队列中没有待处理的任务时,线程进入等待状态
try {
mIsWait = true;// 标识线程的状态,必须在wait()方法之前
synchronized (this) {
this.wait();// 保用线程进入等待状态,直到有新的任务被加入时通知唤醒
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
}
}
.[代码] [Java]代码
private class ProductListAdapter extends BaseAdapter {
private AsynImageLoader mImageAsynLoader;
public ProductListAdapter() {
mImageAsynLoader = new AsynImageLoader(mHandler);
}
@Override
public int getCount() {
int size = Math.min(mLastItemViewIndex + 1,
mDataList.size());
mLastItemViewIndex = size - 1;
return size;
}
@Override
public Object getItem(int position) {
return mDataList.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView =
getLayoutInflater().inflate(https://www.doczj.com/doc/7e1133346.html,yout.product_list_item,
null);
}
ImageView imageView = (ImageView) convertView
.findViewById(R.id.iv_item_product_imag e);
Map
//存放图片所对应的
imageView.setTag(map.get("product_pic_address"));
mImageAsynLoader.loadBitmap(imageView, mDefautBitmap); return convertView;
}
}
[代码] AAuto
import win.ui;
/*DSG{{*/
var winform = win.form( bottom=399;scroll=1;text="QQ微博内容快速清空小工具 - 使用AAuto语言编写官方网站: aau ";right=599;parent=...)
winform.add( )
/*}}*/
import web.form;
var wb = web.form( winform );
win.msgboxTimeout("请先登录微博,您可以最小化窗口本工具仍然可以继续正常运行","QQ 微博内容快速清空小工具")
//在这里输入你的腾迅微博地址
wb.go("t/ecrane/mine")
wb.wait()
winform.show(0x3/*_SW_MAXIMIZE*/ )
for(i=1;1000;1){
var qEle = wb.waitQueryEles( tagName="DIV";className="main" );
qEle.click();
var qEle = wb.waitQueryEles( className="msgBox";tagName="^DIV$" );
qEle.click();
var qEle = wb.waitQueryEles( innerHTML="@更多 class=btn_ldrop>
qEle.click();
var qEle = wb.waitQueryEles( className = "delBtn")
qEle.click();
var qEle = wb.waitQueryEles( value="确定"; type = "button")
if( #qEle ){
qEle.click();
}
else {
wb.refresh3();
wb.wait()
}
wb.wait()
}
win.loopMessage();
[代码] [Java]代码
package cn.jd3g.utils;
import android.os.AsyncTask;
/**
* 自定义异步执行任务类
*
* @author xfzhang
*
*/
public class ShopAsyncTask extends AsyncTask
private Runnable preExecuteListener;//后台线程执行之前的回调监听
private Runnable PostExecuteListener;//后台线程执行完成之后的回调监听 private Runnable doInBackgroudListener;//后台线程的回调监听
public ShopAsyncTask(Runnable preExecuteListener, Runnable PostExecuteListener,
Runnable doInBackgroudListener) {
this.PostExecuteListener = PostExecuteListener;
this.preExecuteListener = preExecuteListener;
this.doInBackgroudListener = doInBackgroudListener;
}
@Override
protected void onPreExecute() {
if (preExecuteListener != null)
preExecuteListener.run();
}
@Override
protected Void doInBackground(Void... params) {
if (doInBackgroudListener != null)
doInBackgroudListener.run();
return null;
}
@Override
protected void onPostExecute(Void result) {
if (PostExecuteListener != null)
PostExecuteListener.run();
}
}
.[代码] [Java]代码
使用工作类:
new ShopAsyncTask(new Runnable() {
@Override
public void run() {
// 显示提示视图等准备工作
}
}, new Runnable() {
@Override
public void run() {
// 更新界面
}
}, new Runnable() {
@Override
public void run() {
// 分线程长时间的业务工作
}
}).execute();
[代码] [Java]代码
/*
* In this function the first part shows how to convert an
* image file to byte array.
* The second part of the code shows how to change byte array
* back to a image
*/
File file = new File("C:\\rose.jpg");
System.out.println(file.exists() + "!!");
FileInputStream fis = new FileInputStream(file);
//create FileInputStream which obtains input bytes from a file in a file system
//FileInputStream is meant for reading streams of raw bytes such as image data. For reading streams of characters, consider using FileReader.
//InputStream in = resource.openStream();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
byte[] buf = new byte[1024];
try {
for (int readNum; (readNum = fis.read(buf)) != -1;) {
bos.write(buf, 0, readNum);
//no doubt here is 0
//Writes len bytes from the specified byte array starting at offset // off to this byte array output stream.
System.out.println("read " + readNum + " bytes,");
}
} catch (IOException ex) {
Logger.getLogger(ConvertImage.class.getName()).log(Level.SEVERE, null, ex);
}
byte[] bytes = bos.toByteArray();
//bytes is the ByteArray we need
/*
* The second part shows how to convert byte array back to an image file */
//Before is how to change ByteArray back to Image
ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
Iterator> readers = ImageIO.getImageReadersByFormatName("jpg");
//ImageIO is a class containing static convenience methods for locating ImageReaders
//and ImageWriters, and performing simple encoding and decoding.
ImageReader reader = (ImageReader) readers.next();
Object source = bis; // File or InputStream, it seems file is OK
ImageInputStream iis = ImageIO.createImageInputStream(source);
//Returns an ImageInputStream that will take its input from the given Object
reader.setInput(iis, true);
ImageReadParam param = reader.getDefaultReadParam();
Image image = reader.read(0, param);
//got an image file
BufferedImage bufferedImage = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_RGB);
//bufferedImage is the RenderedImage to be written
Graphics2D g2 = bufferedImage.createGraphics();
g2.drawImage(image, null, null);
File imageFile = new File("C:\\newrose2.jpg");
ImageIO.write(bufferedImage, "jpg", imageFile);
//"jpg" is the format of the image
//imageFile is the file to be written to.
System.out.println(imageFile.getPath());
[文件] weibo.zip ~ 682KB 下载(1009)
文件不存在或者代码语言不存在
[代码] [Java]代码
package text;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
public class Fire {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args){
// TODO Auto-generated method stub
// System.out.println("请输入如下格式数:2"+"x . "+". x "); boolean t = true;
ArrayList
while(t){
Scanner in = new Scanner(System.in);
int a = in.nextInt();
if(a!=0&&a<5){
// System.out.println(a);
String[][] s = new String[a][a];
for(int i = 0;i < a;i++) {