书签 分享 收藏 举报 版权申诉 / 42

类型信号报告switchcase语句的应用.docx

  • 文档编号:9783556
  • 上传时间:2023-02-06
  • 格式:DOCX
  • 页数:42
  • 大小:26.30KB

FileDescription:


Filetoupload/storeindatabase:

[代码][Java]代码

packagecom.ejintai.test;

importjava.io.FileInputStream;

importjava.io.FileOutputStream;

importjava.io.IOException;

importjava.nio.channels.FileChannel;

publicclassFileCopy

{

publicstaticvoidmain(String[]args)throwsIOException{

Stringsourcefile="E:

\\参考资料\\设计模式.pdf";

Stringtargetfile="E:

\\参考资料\\设计模式1.pdf";

copyfile(sourcefile,targetfile);

}

/**

*

*方法用途:

文件拷贝

*方法名:

copyfile

*返回值:

void

*

*参数:

@paramsourcefile源文件

*参数:

@paramtargetfile目标文件

*参数:

@throwsIOException

*/

privatestaticvoidcopyfile(Stringsourcefile,Stringtargetfile)throwsIOException{

FileChannelsourcefc=newFileInputStream(sourcefile).getChannel();

FileChanneltargetfc=newFileOutputStream(targetfile).getChannel();

sourcefc.transferTo(0,sourcefc.size(),targetfc);

//上面没有进行文件是否存在的判断和异常的处理

}

}

[代码]pythonsqlite3的常规使用

#Filename:

DBcon.py

importsqlite3

importtime

conn=sqlite3.connect(r'D:

\Exercise\Python\DB\example.db')

c=conn.cursor()

c.execute("Createtableifnotexistsstocks(datetext,transtext,symboltext,qtyreal,pricereal)")

flag=raw_input("Doyouwannacleanthetable?

(y/n):

")

ifflag=='y':

c.execute("deletefromstocks")

c.execute("Insertintostocksvalues('"+time.strftime('%Y-%m-%d%H:

%m:

%S')+"','Buy','Rhatd',1000,23.14)")

connmit()

c.execute('select*fromstocks')

res=c.fetchall()

count=0

printres

print'-'*60

forlineinres:

forfinline:

count=count+1

printcount,f,

print

print'-'*60

print'-'*60

print'Thereare%drecords!

'%count

c.close()

conn.close()

[代码][Shell/批处理]代码

MACADDR="52:

54:

$(ddif=/dev/urandomcount=12>/dev/null|md5sum|sed's/^\(..\)\(..\)\(..\)\(..\).*$/\1:

\2:

\3:

\4/')";echo$MACADDR

[文件]PathUtil.java ~ 3KB    (10)

packagesmoke;

importjava.util.LinkedList;

importjava.util.List;

importjava.util.Stack;

publicclassPathUtil{

publicstaticListfind(int[][]matrix){

intWIDTH=matrix.length;

intHEIGHT=matrix[0].length;

int[][]used=newint[WIDTH][HEIGHT];

TreeNoderoot=newTreeNode();

root.setFather(null);

root.setX(0);

root.setY(0);

TreeNodetail=buildTree(root,matrix,used);

if(tail!

=null)

{

Stackstack=newStack();

TreeNodecurrent=tail;

for(;;)

{

if(current==null){

break;

}

Pospos=newPos();

pos.x=current.getX();

pos.y=current.getY();

stack.push(pos);

current=current.getFather();

}

Listlist=newLinkedList();

while(stack.size()>0)

{

list.add(stack.pop());

}

returnlist;

}

returnnull;

}

privatestaticTreeNodebuildTree(TreeNodecurrent,int[][]matrix,int[][]used)

{

intWIDTH=matrix.length;

intHEIGHT=matrix[0].length;

intx=current.getX();

inty=current.getY();

if(x+1

{

if(matrix[x+1][y+1]==0&&matrix[x+1][y]==0&&matrix[x][y+1]==0&&used[x+1][y+1]==0)

{

TreeNodenode=newTreeNode();

node.setFather(current);

node.setX(x+1);

node.setY(y+1);

current.getChildren().add(node);

used[x+1][y+1]=1;

if(x+1==WIDTH-1&&y+1==HEIGHT-1)

{

returnnode;

}

}

}

if(x+1

{

if(matrix[x+1][y]==0&&used[x+1][y]==0)

{

TreeNodenode=newTreeNode();

node.setFather(current);

node.setX(x+1);

node.setY(y);

current.getChildren().add(node);

used[x+1][y]=1;

if(x+1==WIDTH-1&&y==HEIGHT-1)

{

returnnode;

}

}

}

if(y+1

{

if(matrix[x][y+1]==0&&used[x][y+1]==0)

{

TreeNodenode=newTreeNode();

node.setFather(current);

node.setX(x);

node.setY(y+1);

current.getChildren().add(node);

used[x][y+1]=1;

if(x==WIDTH-1&&y+1==HEIGHT-1)

{

returnnode;

}

}

}

if(y-1>=0)

{

if(matrix[x][y-1]==0&&used[x][y-1]==0)

{

TreeNodenode=newTreeNode();

node.setFather(current);

node.setX(x);

node.setY(y-1);

current.getChildren().add(node);

used[x][y-1]=1;

}

}

if(x-1>=0)

{

if(matrix[x-1][y]==0&&used[x-1][y]==0)

{

TreeNodenode=newTreeNode();

node.setFather(current);

node.setX(x-1);

node.setY(y);

current.getChildren().add(node);

used[x-1][y]=1;

}

}

if(x-1>=0&&y-1>=0)

{

if(matrix[x-11][y-11]==0&&matrix[x-1][y]==0&&matrix[x][y-1]==0&&used[x-1][y-1]==0)

{

TreeNodenode=newTreeNode();

node.setFather(current);

node.setX(x-1);

node.setY(y-1);

current.getChildren().add(node);

used[x-1][y-1]=1;

}

}

Listlist=current.getChildren();

if(list.size()<=0)

{

returnnull;

}

for(TreeNodenode:

list)

{

TreeNodetail=buildTree(node,matrix,used);

if(tail!

=null)

{

returntail;

}

}

returnnull;

}

}

[文件]Pos.java ~ 73B    (8)

packagesmoke;

publicclassPos{

publicintx;

publicinty;

}

[文件]TreeNode.java ~ 626B    (8)

packagesmoke;

importjava.util.ArrayList;

importjava.util.List;

publicclassTreeNode{

privateTreeNodefather;

privateListchildren;

privateintx;

privateinty;

publicTreeNode()

{

children=newArrayList();

}

publicvoidsetFather(TreeNodefather){

this.father=father;

}

publicTreeNodegetFather(){

returnfather;

}

publicListgetChildren(){

returnchildren;

}

publicvoidsetX(intx){

this.x=x;

}

publicintgetX(){

returnx;

}

publicvoidsetY(inty){

this.y=y;

}

publicintgetY(){

returny;

}

}

[代码][PHP]代码

classUser{

staticfunctiongetInstance()

{

if(self:

:

$instance==NULL){//Ifinstanceisnotcreatedyet,willcreateit.

self:

:

$instance=newUser();

}

returnself:

:

$instance;

}

privatefunction__construct()

//Constructormethodasprivatesobymistakedevelopernotcrate

//secondobjectoftheUserclasswiththeuseofnewoperator

{

}

privatefunction__clone()

//Clonemethodasprivatesobymistakedevelopernotcrate

//secondobjectoftheUserclasswiththeuseofclone.

{

}

functionLog($str)

{

echo$str;

}

staticprivate$instance=NULL;

}

User:

:

getInstance()->Log("WelcomeUser");

[代码][JavaScript]代码

(function(){

vari=null;

functionk(){

returnFunction.prototype.call.apply(Array.prototype.slice,arguments)

}

functionl(a,b){

varc=k(arguments,2);

returnfunction(){

returnb.apply(a,c)

}

}

functionm(a,b){

varc=newn(b);

for(c.f=[a];c.f.length;){

vare=c,

d=c.f.shift();

e.g(d);

for(d=d.firstChild;d;d=d.nextSibling)d.nodeType==1&&e.f.push(d)

}

}

functionn(a){

this.g=a

}

functiono(a){

a.style.display=""

}

functio

配套讲稿:

如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。

特殊限制:

部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。

关 键  词:
信号 报告 switchcase 语句 应用
提示  冰豆网所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。
关于本文
本文标题:信号报告switchcase语句的应用.docx
链接地址:https://www.bdocx.com/doc/9783556.html
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2008-2022 冰点文档网站版权所有

经营许可证编号:鄂ICP备2022015515号-1

收起
展开