现在位置: 首页 > shissunny发表的所有文章
  • 11月
  • 10日
综合 ⁄ 共 502字 评论关闭
判断是否数字,考虑多种情况 class Solution{ public: bool isNumber(string s){ int i = 0; while(s[i] == ' ') ++i; while(s[i] == '+' || s[i] == '-') ++i; bool exp = false, space = false, point = false, number = false; while(s[i] != '\0'){ if(isdigit(s[i])){ if(space) return false; else number = true; } else if(s[i] == '.'){ if(!point && !space && !exp) point = true; else return false; } else if......
阅读全文
  • 08月
  • 25日
综合 ⁄ 共 2918字 评论关闭
现在比较流行的开放IM协议包括SIP、SIMPLE和XMPP(jabber)。对XMPP做一个简单介绍。 目前XMPP协议的使用的案例还相对较少,主要是Google的gtalk和Nokia新推出的Ovi。 XMPP设计了一个在互联网上唯一的标识,用JID来表达。通常一个 JID 由三部分组成,node@domain/resource 。和email很像,但比 email 的表达形式多了一个 /resource用来表达这个实体下的具体事物。例如ip地址和port的关系。通过不同的resource的区别使 XMPP 实现一个帐号在多处登录,例如,gtalk允许一个帐号的多处登录。 XMPP 规范的重要的通信协议是:如何把消......
阅读全文
  • 05月
  • 14日
综合 ⁄ 共 8982字 评论关闭
gprof介绍 gprof是GNU profiler工具。可以显示程序运行的“flat profile”,包括每个函数的调用次数,每个函数消耗的处理器时间。也可以显示“调用图”,包括函数的调用关系,每个函数调用花费了多少时间。还可以显示“注释的源代码”,是程序源代码的一个复本,标记有程序中每行代码的执行次数。 为gprof编译程序 在编译或链接源程序的时候在编译器的命令行参数中加入“-pg”选项,编译时编译器会自动在目标代码中插入用于性能测试的代码片断,这些代码在程序在运行时采集并记录函数的调用关系和调用次数,以及采集并记录函数自身执行时间......
阅读全文
  • 12月
  • 28日
综合 ⁄ 共 1085字 评论关闭
      #include<stdio.h> #include<queue> using namespace std; #define N 1005 struct node { int x,y,gw,fx; }; int n,m,t,sx,sy,sz,ex,ey,ez,h,dir[4][2]={0,-1, 0,1, -1,0, 1,0}; int map[N][N]; char ev[N][N]; int judge(int x,int y) { if(x>0 && x<=n && y>0&&y<=m && map[x][y]==0&&ev[x][y]=='0') return 1; return 0; } int bfs(int x,int y) { queue<node>q; node cur,next; int k; cur.x=x; cur.y=......
阅读全文
  • 07月
  • 11日
综合 ⁄ 共 3732字 评论关闭
#include  <algorithm> #include  "afxtempl.h" //TYPE类必须有< template<class TYPE, class ARG_TYPE> void Sort(CArray<TYPE,ARG_TYPE>& dest) {  std::sort(dest.GetData(),dest.GetData()+dest.GetSize()); } //构造一个有序序列,该序列仅保留第一个序列中存在的而第二个中不存在的元素。 //src1,src2必须已排序 template<class TYPE, class ARG_TYPE> void SetDifference(CArray<TYPE,ARG_TYPE>& dest,const CArray<TYPE,ARG_TYPE>& src1,const CArray<TYPE,ARG_TYP......
阅读全文
  • 07月
  • 05日
综合 ⁄ 共 1297字 评论关闭
zlib是用于数据压缩的函数库,在windows和linux上都被广泛应用。当然,windows mobile上也可以顺利地使用该函数库。 先进入到下面的地址去下载一个包,是专门针对wince系统的:http://www.tenik.co.jp/~adachi/wince/zlibce/index.html。其中Download有三项,如果你并不想深入源码的话,选择第三项zlib for WindowsCE Ver.1.1.4(with binaries)。 下载到本地后解开,在zlibce目录下,有我们需要的头文件zconf.h和zlib.h;至于库文件则在zlibce/WCE400/ARMV4I下,zlibce.lib。 在VS2005(ECV4.0当然也可以)下新建一测试工程,把上述......
阅读全文
  • 06月
  • 07日
综合 ⁄ 共 1618字 评论关闭
using UnityEngine; using System.Collections; using System; using System.Runtime.Serialization; using System.IO; using System.Runtime.Serialization.Formatters.Binary; [Serializable] public class Employee{public int Empld=100;public string name="陈哲";[NonSerialized]public string NoSerializable="No-Serializable";public Employee(){ }     /*public Employee(SerializationInfo info,StreamingContext ctxt){         Empld = (int)info.GetValue("EmId",typeof(int));         name = (string)info.GetVal......
阅读全文
  • 05月
  • 05日
综合 ⁄ 共 2823字 评论关闭
前言 android gradle 插件已经发展到0.5.7,同时gradle 本身也到了1.8,相比两个月前,android gradle 更快,更完善,也更好用了,为了让各位androider 早日用上gradle这样的神器,特地写一篇关于gradle一些奇葩错误的解决指南. 使用最新的gradle android插件 以前我们写的时候会这么写 dependencies { classpath 'com.android.tools.build:gradle:0.5.0' } 不过,由于android gradle 插件的开发还是很活跃的,而且目前而言,可能还存在一些我们不知道的坑,但是,别人踩过,后边,官方修复,为了不踩坑,我建议android gradle 始终保持最......
阅读全文
  • 04月
  • 26日
综合 ⁄ 共 712字 评论关闭
package com.lxh.test; import java.io.*;/* * lxh */ public class Test { public static void main(String[] args) throws Exception  {  String line;  String physicalAddress = "read MAC error!";   try {   Process p=Runtime.getRuntime().exec("cmd.exe /c ipconfig /all");   //p.waitFor();   BufferedReader bd =new BufferedReader(new InputStreamReader (p.getInputStream()));    while((line=bd.readLine())!=null){    if(line.indexOf("Physical Address. . . . . . . . . :")!=-1){     if(line.indexOf(":")!......
阅读全文
  • 03月
  • 18日
综合 ⁄ 共 190字 评论关闭
1. 发现centos中/etc/xinetd.d下没有daytime,解决方法: 1.1 先安装一个 xinetd: yum install xinetd; 1.2 然后修改 /etc/xinetd.d/daytime-stream和 /etc/xinetd.d/ daytime-dgram 中的disable为no; 1.3 重启 xinetd 服务:/etc/init.d/xinetd restart即可。
阅读全文
  • 02月
  • 12日
综合 ⁄ 共 8688字 评论关闭
1.概述 SharedPreferences是Android提供用来存储一些简单配置信息的机制,其以KEY-VALUE对的方式进行存储,以便我们可以方便进行读取和存储。主要可以用来存储应用程序的欢迎语、常量参数或登录账号密码等。 2.实例 (1)创建项目SharedPreferencesDemo项目 (2)编辑主界面的布局文件main.xml如下: [xhtml] view plaincopy <?xml version="1.0" encoding="utf-8"?>   <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"       android:orientation="vertical"       android:l......
阅读全文
class   A{} A中包含有: JFrame   frameA; JButton   btnA; class   B{} B中包含有: final   JFrame   frameB; Static   boolean   wantToSave   =   true; frameB.addWindowListener(   new   WindowAdapter() {   pubilic   void   windowClosing(windowEvent   we) {JDialog   dlg   } ........... } ); 问题描述:实现的功能是每点击一次btnA则弹出一个frameB(即一个class   B的instance被new)。当要关闭frameB的时候dlg弹出提示我选择Yes/No/No   to   all,当选No   to   all的时候(此时将wantToSave设成f......
阅读全文