易截截图软件、单文件、免安装、纯绿色、仅160KB

javaSocket客户端与C服务端通信

转自:http://hi.baidu.com/ssrt_hanbing/blog/item/62e3b934598eeb82a71e1238.html
通过高低位转换。
package com.commnt;
import java.net.*;
import java.io.*;
public class Client {
public String send(String address, int port, String str) {
   OutputStream os = null;
   DataInputStream is = null;
   String look = "";
   Socket socket = null;
   try {
    socket = new Socket(address, port);
    os = socket.getOutputStream();
    byte[] phone = new byte[str.length()];
    phone = ByteUtil.StringtoBytes(phone, str);
    os.write(phone);
    os.flush();
    is = new DataInputStream(socket.getInputStream());
    byte[] phone1 = new byte[str.length()];
    is.read(phone1);
    String strBype = new String(phone1);
    look = strBype.toString();
   } catch (UnknownHostException e) {
    e.printStackTrace();
   } catch (IOException e) {
    e.printStackTrace();
   } finally {
    close(socket, is, os);
   }
   return look;
}
public void close(Socket socket, DataInputStream is, OutputStream os) {
   if (os != null)
    try {
     os.close();
    } catch (IOException e) {
     e.printStackTrace();
    }
   if (is != null)
    try {
     is.close();
    } catch (IOException e) {
     e.printStackTrace();
    }
   if (socket != null)
    try {
     socket.close();
    } catch (IOException e) {
     e.printStackTrace();
    }
}
}
public class ByteUtil


相关文档:

C bomb。。。。FML~~~

输出斐波那契数列前N个合数,四个一行,N由使用者输入,介于10到30之间。
#include<stdio.h>
#include<math.h>
int fab(int);
int judge(int);
int main()
{
int a[30]={0};
int i,n,t=0;
do
{
printf("Input the number\n");
scanf("%d",&n);
}
while(n>3 ......

对C宏定义的小小实践

用宏实现一个swap功能
#include <stdio.h>
#include <stdlib.h>
#define SWAP( TYPE,ARG1,ARG2 ) \
void TYPE##Swap( TYPE *p, TYPE *q ) \
{ \
TYPE tmp = *p; \
*p = *q; \
*q = tmp; \
} \
TYPE##Swap(&ARG1,&ARG2 ......

汉诺塔算法的递归与非递归的C以及C++源代码



汉诺塔算法的递归与非递归的C以及C++源代码
By Minidxer | January 30, 2008
汉诺塔(又称河内塔)问题其实是印度的一个古老的传说。
开天辟地的神勃拉玛(和中国的盘古差不多的神吧)在一个庙里留下了三根金刚石的棒,第一根上面套着64个圆的金片,最大的一个在底下,其余一个比一个小,依次叠上 ......

C程序:输出1,2,3,..,n的所有组合数

/*
思路:递归算法
从开始往后递增地写数字,当前从now值开始,存储的位置从cur开始,
则显然加上,now..n,都是新的组合数,对于每一个,{ 输出之,然后递归,处理 _c(n, cur+1, a, i+1) }
*/
/* 输出1,2,3,..,n的组合数 */
#include <stdio.h>
#include <assert.h>
#include <malloc.h>
void ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号