当前位置: 编程技术>综合
本页文章导读:
▪一个比较困扰的SVN问题 情况:
SVN更新多次之后会出现错误:
Server sent unexpected return value (403 Forbidden) in response to OPTIONS
解决:
使用switch 重新定位svn路径
作者:initphp 发表于2013-1-5 17:37:12 原文链.........
▪Android一句话区分sendBroadcast与sendStickyBroadcast 小例实现步骤:
①.在MainActivity里面发送两种类型的广播:sendBroadcast和sendStickyBroacat。
②在ReceverActivity里面通过BroadcastReceiver来接收这两个消息,这里是通过代码来注册Recevier而不是在Manifest里.........
▪UVA 152 - Tree's a Crowd 原本以为精度问题,原来是最后需要一个换行。直接暴力是0.216,如果加个弱弱的排序优化一下是0.120。
#include <stdio.h>
#include <math.h>
#include <string.h>
#include .........
[1]一个比较困扰的SVN问题
来源: 互联网 发布时间: 2013-11-05
情况:
SVN更新多次之后会出现错误:
Server sent unexpected return value (403 Forbidden) in response to OPTIONS
解决:
使用switch 重新定位svn路径
作者:initphp 发表于2013-1-5 17:37:12 原文链接
阅读:0 评论:0 查看评论
[2]Android一句话区分sendBroadcast与sendStickyBroadcast
来源: 互联网 发布时间: 2013-11-05
小例实现步骤:
①.在MainActivity里面发送两种类型的广播:sendBroadcast和sendStickyBroacat。
②在ReceverActivity里面通过BroadcastReceiver来接收这两个消息,这里是通过代码来注册Recevier而不是在Manifest里面注册的。
③结论:通过sendBroadcast中发出的intent在ReceverActivity不处于onResume状态是无法接受到的,即使后面再次使其处于该状态也无法接受到。而sendStickyBroadcast发出的Intent当ReceverActivity重新处于onResume状态之后就能重新接受到其Intent。这就是the Intent will be held to be re-broadcast to future receivers这句话的表现。就是说sendStickyBroadcast发出的最后一个Intent会被保留,下次当Recevier处于活跃的时候,又会接受到它。
④在wifi中就是发送的粘性广播。
下面是两个类的代码部分。
MainActivity:
public class MainActivity extends Activity {
Button btnSendi;
Button btnSends;
Button btnStart;
Context mContext;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
btnSendi=(Button) findViewById(R.id.sendi);
btnSends=(Button) findViewById(R.id.sends);
btnStart=(Button) findViewById(R.id.start);
mContext=getApplicationContext();
btnSendi.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent();
intent.setAction("com.android.my.action");
intent.setFlags(1);
mContext.sendBroadcast(intent);
}
});
btnStart.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent(MainActivity.this,ReceiverActivity.class);
startActivity(intent);
}
});
btnSends.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent = new Intent();
intent.setAction("com.android.my.action.sticky");
intent.setFlags(2);
mContext.sendStickyBroadcast(intent);
}
});
}
}
ReceiverActivity :
public class ReceiverActivity extends Activity {
private IntentFilter mIntentFilter;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mIntentFilter = new IntentFilter();
mIntentFilter.addAction("com.android.my.action");
mIntentFilter.addAction("com.android.my.action.sticky");
}
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
System.out.println("action"+action);
}
};
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
registerReceiver(mReceiver, mIntentFilter);
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
unregisterReceiver(mReceiver);
}
}
作者:weidi1989 发表于2013-1-5 17:37:09 原文链接
阅读:0 评论:0 查看评论
[3]UVA 152 - Tree's a Crowd
来源: 互联网 发布时间: 2013-11-05
原本以为精度问题,原来是最后需要一个换行。直接暴力是0.216,如果加个弱弱的排序优化一下是0.120。
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#define sqr(x) ((x)*(x))
typedef struct _Point {
double x, y, z;
}Point;
int cmp(const void *_a, const void *_b) {
Point* a = (Point *)_a;
Point* b = (Point *)_b;
return (int)(a->x - b->x);
}
int main() {
Point p[5005];
int n = 0, r[15];
double x, y, z;
while (scanf("%lf%lf%lf", &x, &y, &z)) {
if (x+y+z < 1e-9) break;
p[n].x = x;
p[n].y = y;
p[n].z = z;
n++;
}
qsort(p, n, sizeof (p[0]), cmp);
memset(r, 0, sizeof (r));
for (int i=0; i<n; i++) {
int tmin = 10;
for (int j=0; j<n; j++) {
if (i == j) continue;
if (p[j].x-p[i].x > 10) // 如果x上距离超过了10不再搜索
break;
int tmp = (int)(sqrt(sqr(p[i].x-p[j].x) + sqr(p[i].y-p[j].y)
+ sqr(p[i].z-p[j].z)));
tmin = tmin < tmp ? tmin : tmp;
}
r[tmin]++;
}
for (int i=0; i<10; i++)
printf("%4d", r[i]);
printf("\n");
return 0;
}
作者:zcube 发表于2013-1-5 17:35:06 原文链接
阅读:0 评论:0 查看评论
最新技术文章: